/    /  OS – Critical Section Problem

Critical Section Problem:

 

A critical section is a piece of the program that can be accessed by a single process at a point in time. 

Simultaneous access to shared resources can lead to unsound behaviour, therefore parts of the program where the shared resource is accessed need to be protected in ways that avoid simultaneous access. This protected section is the critical section or critical region. 

 

Entry in the critical section is handled by the wait() function, and the exit from the critical section is handled by the signal() function.

 

Rules for Critical Section:

 

For the implementation of Critical Section it must enforce three rules:

  1. Mutual Exclusion
  2. Progress
  3. Bound Waiting

 

Mutual Exclusion

Mutual Exclusion is a special type of binary semaphore which is used for controlling access to the shared resource. It makes sure that no more than one process executes in its critical section at a point in time. 

 

Progress

When there are no processes in the critical section, the processes that are not in the reminder section should continue within a certain time period. 

 

Bound Waiting

There exists a limit on the number of times other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.

 

Solutions to Critical Section:

 

Some methods to solve the problem of Critical Section are as follows:

  1. Peterson Solution
  2. Semaphore Solution
  3. Synchronization Hardware
  4. Mutex Locks

 

Reference

Critical Section Problem In Operating System.