A CRITICAL SECTION is
Aany code that uses shared variables
Bcode accessing shared state that must run atomically
Ca section of code that runs only once at boot
Dthe smallest unit a compiler can optimise
Answer & Solution
Correct answer: B. code accessing shared state that must run atomically
1. OSTEP §26.1 defines: a critical section is a block of code that, when executed concurrently by multiple threads, can produce INCORRECT results unless serialised.
2. Example: incrementing a shared counter, adding to a linked list, updating a shared file pointer.
3. The classic protection: surround the critical section with `lock(L); ... unlock(L);`.
4. Not ALL code that uses shared variables is a critical section — code that only READS immutable shared state is safe without locks.
5. Options A, C, D describe broader or wrong concepts.
_Source: OSTEP Ch 26 (Concurrency: An Introduction), §26.1, p. 1-2._
Keep practising Operating Systems
Browse all Operating Systems questions for GATE CSE, or explore more Computer Science topics.
Related questions
On a MULTI-CORE system, a SPIN LOCK is generallyA LIVELOCK differs from a DEADLOCK in thatSuppose thread A acquires lock L1, then thread B acquires lock L2. Now A tries to acquire A LOCK is considered FAIR ifA LOCK (mutex) is used by concurrent threads toWhich of the following is NOT typically minimised by a CPU scheduler?The PRIMARY DISADVANTAGE of FIFO scheduling isJobs A (run time 100, arrival 0), B (run time 10, arrival 0), C (run time 10, arrival 0) u