What is a binary semaphore? What is its use?

Answer Posted / ashaa

The semaphore discussed previously is called a counting sempahore. Another kind of semaphore is the binary semaphore; This is exactly like a counting semaphore except for the following:
the semaphore value is restricted to 0 and 1.
P succeeds only when the semaphore value is 1.
V does not change the semaphore value when it is 1. (Thus successive Vs are lost.)

Binary semaphores are sometimes easier to implement. than counting semaphores. We will not describe implementations of binary semaphores in terms of low-level or OS constructs (these would be similar to the implementations of counting semaphores). Instead we show how counting semaphores can be implemented by binary semaphores, which demonstrates that binary sempahores are as powerful as counting semaphores.
Convention: Unless otherwise mentioned, a semaphore is to be interpreted as a counting semaphore.

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How long should a chkdsk r take?

731


How do I search for a pattern in vi?

678


Explain about local and global page replacements?

694


What is RR scheduling algorithm?

873


What are the benefits and losses of placing the functionality in a device controller rather than in placing it in the kernel?

800






What is LiveLock?

848


Can you please explain the difference between load-time dynamic linking and run-time dynamic linking?

750


What is an operating system on a computer?

742


What is the programs x86 folder?

806


What is the difference between process and program?

715


Is it ok to interrupt chkdsk?

743


Suppose if we have a variable 'I' in run method, if I can create one or more thread each thread will occupy a separate copy or same variable will be shared?

871


Is 100 cpu usage bad?

735


How much ram do I need?

637


What is dedicated processor assignment in operating system (os)?

1086