Nota: A tradução desta entrada está atualmente em revisão de qualidade, portanto parte do conteúdo é exibida temporariamente apenas em inglês.
Este verbete ainda não foi traduzido para o seu idioma, portanto o original é exibido abaixo.
mutex
This term is a portmanteau of mutual exclusion, serving as a technical shorthand in concurrent programming. It evokes the image of a physical lock or a single key to a room, where only one entity can hold the key at a time to ensure data integrity.
In professional software engineering, the word carries a connotation of strict control and safety. It is used almost exclusively in the context of multi-threaded environments to describe the mechanism that prevents race conditions, distinguishing it from other synchronization primitives like semaphores which may allow multiple concurrent accesses.
Meanings
Examples
The program uses a mutex to protect the shared counter.
I forgot to release the mutex and caused a deadlock.
Wait, did you initialize the mutex before starting the threads?
A mutex ensures that only one thread can enter the critical section at a time.
I should probably use a recursive mutex here to avoid self-deadlock.
The system crashed because two threads were fighting over the same mutex.
Is a mutex the best choice for this high-contention scenario?