What is a race condition? Explain how does a critical section avoid this condition. What are the properties which a data item should possess to implement a critical section?

What is race condition?
The situation where several processes access – and manipulate shared data concurrently. The final value of the shared data depends upon which process finishes last. To prevent race conditions, concurrent processes must be synchronized.

Data consistency requires that only one processes should update the value of a data item at any time. This is ensured through the notion of a critical section. A critical section for data item d is a section of code, which cannot be executed concurrently with itself or with other critical sections for d. Consider a system of n processes (P0, P1,..., P n-1), each process has a segment of code called a critical section, in which the proceses may be changing common variables, updating a table, writing a file, and so on. The important feature of the system is that, when one process is executing in its critical section, no other process is to be allowed to execute in its critical section. Thus the execution of critical sections by the processes is mutually exclusive in time. 

Solution to the Critical Section Problem  

The solution must satisfy the following three conditions:
Mutual Exclusion. If process Pi is executing in its critical section, then no other processes can be executing in their critical sections.
Progress. If no process is executing in its critical section and there exist some processes that wish to enter their critical section, then the selection of the processes that will enter the critical section next cannot be postponed indefinitely.
Bounded Waiting. A bound must exist on the number of times that 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.
—Assume that each process executes at a nonzero speed
—No assumption concerning relative speed of the
n processes.


Feel free to contact the admin for any suggestions and help.