FOR FREE YEAR SOLVED

Requirement of Synchronization mechanisms

 

Synchronization mechanism makes a solution for critical section problem or avoids race condition but sometimes it may lead to some disadvantages as below.

 

1) Program code will be increased due to extra code (entry and exit) i.e. execution code may be increased. 

2) For some of the synchronization techniques, the system leads to a deadlock.

3) For some of the synchronization techniques, it leads to mutual exclusion problem.

 

Requirement of Synchronization mechanisms or essential properties of Critical Section implementation: 

1) Mutual execution: No two processes may be simultaneously present inside the critical section at any point of time i.e. only one process is allowed into a critical section at any point of time.

Mutual exclusion ensures that there is no problem of race-condition among processes.

 

2) Progress: A process executing outside of its critical section cannot prevent any other interesting processes which want to enter its critical section. 

The simple concept if one process does not want to enter its critical section, then this process cannot stop another process to enter its critical section.

 

3) Bounded Waiting: No process should have to wait forever to enter into the critical section. 

There should be a bound on the number of times that other processes are allowed to enter into the critical section.

            

4) Portability: No assumption related to hardware architecture and processor speed. 

 The solution must work irrespective of any hardware architecture and processor speed.

 

If any solution (algorithm for process synchronization) is satisfying above all the four requirements then it will be a correct solution for synchronizing the processes.

 

We can divide the process synchronization mechanism in two ways 

1) Synchronization with busy waiting (Spinlock)

2) Synchronization without busy waiting.  

            

Busy Waiting: While a process is in its critical section, any other process that tries to enter its critical section must loop continuously in the call to the critical section entry function.

We can say a more simple way that when one process is in the critical section, any other process that tries to enter in its critical section, then it continuously knocks the critical section then CPU is busy to knock the critical section every time.

This concept is also called a spinlock because the process “spins” while waiting for the lock to become available

 

For example:

The concept is just like a trial room, if one person enters into trial room, and another person comes for trial and busy to knock the door continuously. 

 

Without Busy Waiting: While a process is in its critical section and any other process which is ready to go in its critical section but the critical section is already occupied then this process does not unnecessarily knock the critical section i.e. not call the critical section entry function infinite time, rather go to sleep, until the previous process is finished. 

Here CPU time is not wasted due to call the function (like unnecessary knocking) infinitely to enter into the critical section.