Question: When there is a context switch from one process to another, the OS kernel invokes the function ContextSwitch which saves the context of the

When there is a context switch from one process to another, the OS kernel invokes the function ContextSwitch

When there is a context switch from one process to another, the OS kernel invokes the function ContextSwitch which saves the context of the currently executing process into its PCB and then inserts the process to an appropriate queue (i.e., ready queue or a blocked queue). It is necessary that ContextSwitch is atomic (i.e., unbreakable: either done or not-done; nothing in between). Explain the following: a) Why must ContextSwitch be atomic? b) Give an example scenario of what can go wrong if ContextSwitch is not atomic. c) How can it be made atomic in practice?

Step by Step Solution

3.36 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a Context Switch must be atomic because it involves modifying the state of both the processes being switched ie the current process and the next proce... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!