(Computer Programming) synchronized multiple access to common data sources (uses "lock-unlock" switch that allows access to one program at a time and excludes all others)
Mutual exclusion (often abbreviated to 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. Examples of such resources are fine-grained
flags, counters or
queues, used to communicate between code that runs concurrently, such as an application and its
interrupt handlers. The problem is acute because a
thread can be stopped or started at any time.To illustrate: suppose a section of code is mutating a piece of data over several program steps, when another thread, perhaps triggered by some unpredictable event, starts executing. If this second thread reads from the same piece of data, the data, in the process of being overwritten, is in an inconsistent and unpredictable state. If the second thread tries overwriting that data, the ensuing state will probably be unrecoverable. These
critical sections of code accessing shared data must therefore be protected, so that other processes which read from or write to the chunk of data are excluded from running.
See more at Wikipedia.org...