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