58.0k views
1 vote
A semaphore puts a thread to sleep:

A. if it increments the semaphore's value above 0.

B. until another thread issues a notify on the semaphore.

C. if it tries to decrement the semaphore's value below 0.

User Djokovic
by
5.7k points

1 Answer

1 vote

Answer:

B. until another thread issues a notify on the semaphore.

Step-by-step explanation:

A semaphore is a variable that is shared between threads and is not negative. It also acts as a calling mechanism that uses two atomic operations wait and signal for synchronization of processes.

A thread that is waiting for a process can be signaled by another thread.

A semaphore puts a thread to sleep until another thread issues a notify on the semaphore.

The wait operation will get a semaphore or otherwise wait if the busy S semaphore is available.

The signal operation will release a semaphore or wake a process if there is a thread waiting for S.

User GeniusHawlah
by
4.9k points