Context-Switching
Question 1 |
Which of the following actions is/are typically not performed by the operating system when switching context from process A to process B?
Saving current register values and restoring saved register values for process B.
| |
Changing address translation tables. | |
Swapping out the memory image of process A to the disk. | |
Invalidating the translation look-aside buffer. |
Question 1 Explanation:
A) True.
B) True.
C) False, because swapping is done when the process is suspended and not during context switching.
D) True, Invalidation of TLB is necessary because, if the TLB is not invalidated then the new process might end up using the translation of old process. Note that Invalidation of TLB is necessary but saving and reuse of TLB is not necessary.
B) True.
C) False, because swapping is done when the process is suspended and not during context switching.
D) True, Invalidation of TLB is necessary because, if the TLB is not invalidated then the new process might end up using the translation of old process. Note that Invalidation of TLB is necessary but saving and reuse of TLB is not necessary.
Question 2 |
Which of the following need not necessarily be saved on a context switch between processes?
General purpose registers | |
Translation look-aside buffer | |
Program counter | |
All of the above |
Question 2 Explanation:
We don't need to save TLB or cache to ensure correct program resumption. They are just bonus for ensuring better performance. But PC, stack and registers must be saved as otherwise program cannot resume.
Question 3 |
Consider four processes P, Q, R, and S scheduled on a CPU as per round robin algorithm with a time quantum of 4 units. The processes arrive in the order P, Q, R, S, all at time t = 0. There is exactly one context switch from S to Q, exactly one context switch from R to Q, and exactly two context switches from Q to R. There is no context switch from S to P. Switching to a ready process after the termination of another process is also considered a context switch. Which one of the following is NOT possible as CPU burst time (in time units) of these processes?
P = 4, Q = 10, R = 6, S = 2 | |
P = 2, Q = 9, R = 5, S = 1 | |
P = 4, Q = 12, R = 5, S = 4 | |
P = 3, Q = 7, R = 7, S = 3 |
Question 3 Explanation:
The Gantt chart can be assumed as :
The combinations of given context switches are possible for options A,B and C. However, we can observe that option D does not follow the context switch. Hence, D is the answer.
The combinations of given context switches are possible for options A,B and C. However, we can observe that option D does not follow the context switch. Hence, D is the answer.
There are 3 questions to complete.
