• S
    SwaseekhGATE Preparation
General
  • Dashboard
  • Syllabus
  • Questions
  • Aptitude
  • Mock Tests
  • TCS NQT 2026
Account
  • Pricing
  • Contact
  1. GATE CS
  2. PYQs
  3. Operating System

Semaphore operations are atomic because they are implemented within the OS _________.

GATE 1990 · Operating System · Semaphore · medium

Answer: Semaphore operations are atomic because they are implemented within the OS kernel, where the OS can disable interrupts or use hardware atomic primitives to prevent any interruption during the read-modify-write sequence.

  1. Why atomicity is needed: If wait(S) is not atomic, two processes could simultaneously read S=1, both see it as positive, both enter the critical section — defeating mutual exclusion.
  2. How the OS kernel ensures atomicity: Semaphore operations are implemented as system calls in the kernel. Inside the kernel, the OS can: (a) disable hardware interrupts before the operation and re-enable after (uniprocessor), or (b) use hardware atomic primitives (test-and-set, compare-and-swap) on multiprocessors. This ensures no context switch or concurrent access can occur during the operation.