Critical Section

Concurrent processes or threads can lead to unexpected or erroneous behavior if shared resource is not protected. To avoid unexpected or erroneous behavior, we use protected shared resource. This protected section is called critical section or critical region. The goal of critical section is no other process is allowed to execute in its critical section when a process is executing in critical section.                           



                          /* Entry Section; */

                           Critical_Section ();

                           Remainder_Section ();

                           /* Exit Section; */    


                While ( true )

It is also assumed that (1) after a process enters into critical section, it will eventually exit the critical section; (2) a process may terminate in the non-critical section.