What is a Race Condition, and what three criteria must a solution to the Critical Section problem satisfy?
A race condition occurs when multiple concurrent threads access and manipulate shared data concurrently, and the final outcome depends on the non-deterministic order of execution. To prevent race conditions, access to shared data within critical sections must be synchronized. Edsger Dijkstra established that any valid critical section solution must satisfy three requirements: (1) Mutual Exclusion: only one thread can execute in its critical section at any time; (2) Progress: if no thread is in its critical section, only threads wishing to enter can participate in deciding who enters, and this cannot be delayed indefinitely; and (3) Bounded Waiting: there must be an upper bound on the number of times other threads enter their critical sections after a thread has requested entry, preventing starvation.