Critical section is a code segment that accesses shared variables and has to be executed as an atomic action. There is no assumption about the hardware and number of processor supported.

Critical section has to be executed as an atomic action on accesses shared variables.

There are three requirements of critical section that should be satisfied:

(i) Mutual Exclusion

(ii) Progress, and

(iii) Bounded Waiting

Mutual Exclusion

In simple term no two processes may be simultaneously inside the same critical section. When a process is executing in its critical section, no other processes can be executing in their critical sections.Mutual exclusion can avoid race condition. This is most basic requirement for the solution.

Progress

No process running outside its critical region may block other processes. Suppose that no process in the critical section, and one or more processes want to enter into the critical section, then one of them must be able to enter into critical section. A process executing outside of its critical section can not prevent other processes from entering theirs critical section.

One those processes waiting for critical section must take part in arbitration in a finite amount of time.

Bounded Waiting

No process should have to wait forever to enter a critical section. Bounded waiting ensures that there is no starvation that means a process can not wait indefinite amount of time. There must exist a bound on the of times that other processes are allowed to enter their critical sections before the request is granted.

Contributor's Info

Created:

0Comment

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.

Do

{

/* 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.