Practice free →
HomeGATE CSEcomputerscienceOperating Systems › A LOCK (mutex) is used by concurrent threads to

A LOCK (mutex) is used by concurrent threads to

Aincrease the speed of single-threaded code
Bavoid the need for any context switches
Cautomatically detect deadlocks at runtime
Densure mutual exclusion in a critical section
Answer & Solution
Correct answer: D. ensure mutual exclusion in a critical section
1. OSTEP §28.1 defines locks: a synchronisation primitive used to enforce MUTUAL EXCLUSION around a CRITICAL SECTION. 2. Usage pattern: `lock(L); // critical section ... unlock(L);`. Only one thread holds the lock at a time; others wait. 3. Mutual exclusion ensures that race conditions inside the critical section cannot corrupt shared state. 4. Options A, C, D misstate the purpose. Locks do NOT speed up single-threaded code, avoid context switches, or detect deadlocks. _Source: OSTEP Ch 28 "Locks", §28.1 (Locks: The Basic Idea), p. 1-2._
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions