Skip to content

ISRO Scientist/Engineer CSE 2020Operating Systems › Process Synchronization

ISRO Scientist/Engineer CSE 2020 PYQ: The hardware implementation which provides mutual exclusion is

The hardware implementation which provides mutual exclusion is

  1. A
    Semaphores
  2. B
    Test and set instructions
    Correct answer
  3. C
    Both options
  4. D
    None of the options

Answer

(B) Test and set instructions

Approach

Mutual exclusion requires an atomic operation that can inspect and modify a shared lock without interruption. The test-and-set instruction is a CPU-level hardware instruction that does exactly this: it atomically reads the old value of a memory location and writes a new value (typically setting a lock flag to true). If the old value was false, the calling process has acquired the lock and may enter its critical section; otherwise it must wait/retry. Because this is provided directly by the instruction set, it is rightly called a hardware implementation of mutual exclusion.

Semaphores, by contrast, are a higher-level synchronization abstraction. A semaphore provides wait/P and signal/V operations, but those operations must themselves be made atomic. That atomicity is typically ensured using hardware primitives such as test-and-set or swap, or by disabling interrupts, or with OS support. Therefore, a semaphore is not itself a hardware implementation; it is a software/OS-level construct that depends on underlying atomic hardware support.

So the only option that is actually a hardware implementation providing mutual exclusion is 'Test and set instructions'. 'Both options' is incorrect because semaphores are not hardware. 'None of the options' is incorrect because test-and-set does provide mutual exclusion. Hence the correct answer is option B.

Reviewed by ISRO IQ Editorial Team.