Question

Why must ContextSwitch be atomic and how to achieve this in practice?

I think it must be atomic because if it doesn't save the state of previous processes completely, it can cause problems for future contextSwitches.Inaccuracy, and wrong data.

And to achieve this, can we can use locks?

Does this make sense or am I oversimplifying things.

Was it helpful?

Solution

probably the same assignment as you.

As the save operation requires several steps to save the value of CPU registers, process state, memory-management information, etc.. It is in fact necessary to make the context-switch atomic to ensure consistency.

To do it, it is possible to make the save method and probably the load method "synchronized", in order to make their respective steps execute in one block.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top