A semaphore is a shared integer variable __________

2024

A semaphore is a shared integer variable __________

Answer: A. that can not drop below zeroConceptA semaphore represents a non-negative count used for synchronization. A wait operation decrements a positive count atomically; when the count is zero,…

  1. A.

    that can not drop below zero

  2. B.

    that can not be more than zero

  3. C.

    that can not drop below one

  4. D.

    that can not be more than one

Attempted by 336 students.

Show answer & explanation

Correct answer: A

Concept

A semaphore represents a non-negative count used for synchronization. A wait operation decrements a positive count atomically; when the count is zero, the caller blocks instead of making the count negative.

Application

The permitted values therefore begin at 0 and may rise above 1 for a counting semaphore. The shared integer cannot drop below zero.

Cross-check

  • A count of 0 represents no currently available permit, so 1 cannot be the lower bound.

  • A counting semaphore may represent several permits, so neither 0 nor 1 is a general upper bound.

Result: the semaphore cannot drop below zero.

Explore the full course: Deloitte Nla

Loading lesson…