- The Operations P(S) & V(S) needs to be atomic.
- A process exiting the CS will call V(S)
- ‘Busy-Wait’ solutions to the Critical Section are typically implemented using machine instructions that execute in the Kernel mode
- All of the above
The correct answer given for this question is (4) All of the above. And explaination is given as:
All the given statements are Basic definitions of Synchronization constraints
But I had a doubt regarding option number 3. I think this option is incorrect.
My thought process here is:
- context switching is initiated is via interrupts caused by external or internal events. Example, in round-robin scheduling, when the time quanta is over, a timing device will trigger an interrupt which will intitate the context-switch of the process.
- instructions running in the kernel mode generally have IEN = 0 (interrupt enable flag set to zero i.e. interrupts disabled) and hence they cannot be interrupted. Effectively they cannot be pulled out of execution until a particular block of code is completely executed.
Taking the above two points, a "Busy-wait" solution of synchronization implemented in kernel mode might get stuck in execution and never come out of execution (i.e. will not get preempted). And hence option number (3) is incorrect.
For example, a busy-waiting code like:
while (x == 0); // x currently is 0
if executed in kernel mode, will not be preempted and the "other" processes that sets x to a non-zero value (and allow the above process to enter the critical section) will never be able to run.
Are my points incorrect? Please advice.