Thursday, December 11, 2008

Race Conditions and Mutexes

A race condition or race hazard is a flaw in a system or process whereby the output and/or result of the process is unexpectedly and critically dependent on the sequence or timing of other events. The term originates with the idea of two signals racing each other to influence the output first. Race conditions can occur in electronics systems, especially logic circuits, and in computer software, especially multithreaded or distributed programs.

Mutual exclusion (mutex) algorithms are used in concurrent programming to avoid the simultaneous use of a common resource, such as a global variable, by pieces of computer code called critical sections. Critical sections of code accessing shared data must be protected, so that other processes which read from or write to the chunk of data are excluded from running.
A mutex is also a common name for a program object that negotiates mutual exclusion among threads, also called a lock.

No comments: