edited by
3,219 views
0 votes
0 votes
  1. The Operations P(S) & V(S) needs to be atomic.
  2. A process exiting the CS will call V(S)
  3. ‘Busy-Wait’ solutions to the Critical Section are typically implemented using machine instructions that execute in the Kernel mode
  4. 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:

  1. 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.
  2. 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
 
CS

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. 

edited by

1 Answer

4 votes
4 votes

Option 1 and 2 are apt


The Operations P(S) & V(S) needs to be atomic.

This is True . Semaphore Operations Wait & Signal are always atomic

A process exiting the CS will call V(S)

This is true . Process entering CS is by aquiring resourses  and leave CS by releasing the CS.
 

3.‘Busy-Wait’ solutions to the Critical Section are typically implemented using machine instructions that execute in the Kernel mode
This is also not always necessary

Busy Waiting Solution Of Critical Sections Problems are of Two Types

  • Busy Waiting
  • Non-Busy Waiting

In Busy Waiting there are many solutions . Of which includes

  • Harware Implemetation
  1. TSL
  2. SWAP
  3. Fetch and Add or Test and Add 
  • Software Implementation
  1.  Lock Variable
  2. Strict Alternation
  3. Peterson Solutions
  4. Dekkers Algorithm                 
edited by

Related questions

0 votes
0 votes
1 answer
3
Shefali asked Aug 14, 2015
1,529 views
(a) If $R$ is regular and $N$ is non-regular, then there exists $R+N$, which is regular.(b) If $R$ is regular and $N$ is non-regular, then there exists $R+N$, which is no...