In operating systems, what is a binary semaphore and how is it typically used in process synchronisation?

Difficulty: Easy

Correct Answer: A synchronisation primitive that can take only the values zero or one and is used to implement mutual exclusion or simple signalling between processes or threads.

Explanation:


Introduction / Context:
Semaphores are classic synchronisation primitives introduced in operating system theory to coordinate concurrent processes and threads. A binary semaphore is a simple but powerful variant. This question asks you to recognise what a binary semaphore is and how operating systems use it for basic synchronisation tasks such as mutual exclusion and signalling.


Given Data / Assumptions:

  • Processes or threads may need to coordinate access to shared resources.
  • Semaphores are available as operating system or library constructs.
  • A binary semaphore is restricted to two possible values.
  • No numerical derivation is required.


Concept / Approach:
A general semaphore can hold a non negative integer value and supports operations that increment or decrement that value with possible blocking. A binary semaphore is restricted to values zero and one. When used for mutual exclusion, the value one indicates that the resource is free and zero indicates that it is locked. Processes perform wait or down operations to acquire the semaphore and may block if the value is zero, and perform signal or up operations to release it. Binary semaphores can also be used as simple event flags or signals between threads, enforcing ordering constraints in concurrent execution.


Step-by-Step Solution:
Step 1: Recall that semaphores are used to control access to shared resources and coordinate processes. Step 2: Distinguish a binary semaphore from a counting semaphore by noting that it only takes values zero and one. Step 3: Note that zero usually represents unavailable or locked, and one represents available or unlocked. Step 4: Consider common uses such as protecting critical sections or signalling completion of an operation. Step 5: Choose the option that explicitly describes both the two valued nature and the role in mutual exclusion or signalling.


Verification / Alternative check:
If you look at typical operating system APIs, many provide binary semaphores or mutexes that behave like binary semaphores. Documentation often explains that these objects take values locked or unlocked and are used to guard critical regions. This reinforces the idea that the correct option is the one that links binary semaphores with mutual exclusion and simple signalling between concurrent entities.


Why Other Options Are Wrong:
Option B is incorrect because disk geometry is not related to synchronisation and does not use semaphore semantics. Option C suggests that semaphores are limited to graphical programming, which is false; they are general purpose synchronisation tools. Option D mentions file systems and backups, which again have no direct relationship to the abstract synchronisation mechanism described by semaphores.


Common Pitfalls:
A frequent confusion is between binary semaphores and mutexes. Although they are very similar, mutexes often have ownership semantics while binary semaphores may not. Another pitfall is assuming that semaphores only count available units of a resource; in the binary case they often behave more like simple locks or events. Understanding this helps when reading code and reasoning about concurrency problems.


Final Answer:
A binary semaphore is a synchronisation primitive that can take only the values zero or one and is used to implement mutual exclusion or simple signalling between processes or threads.

More Questions from Operating Systems

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion