Start learning →

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._
Practise this question with Quill — GATE CSE →

Keep practising Operating Systems

Browse all Operating Systems questions for GATE CSE, or explore more Computer Science topics.

Start a Operating Systems lesson →
Related questions