Operating System semaphore - What is a semaphore?

What is a semaphore?

A semaphore is a variable. There are 2 types of semaphores:

Binary semaphores

- Binary semaphores have 2 methods associated with it. (up, down / lock, unlock)
- Binary semaphores can take only 2 values (0/1). They are used to acquire locks. When a resource is available, the process in charge set the semaphore to 1 else 0.

Counting semaphores

- Counting Semaphore may have value to be greater than one, typically used to allocate resources from a pool of identical resources

What is difference between binary semaphore and mutex?

The differences between binary semaphore and mutex are:

- Mutex is used exclusively for mutual exclusion. Both mutual exclusion and synchronization can be used by binary.
- A task that took mutex can only give mutex.
- From an ISR a mutex can not be given.
- Recursive taking of mutual exclusion semaphores is possible. This means that a task that holds before finally releasing a semaphore, can take the semaphore more than once.
- Options for making the task which takes as DELETE_SAFE are provided by Mutex, which means the task deletion is not possible when holding the mutex.

What is a semaphore?

A semaphore is hardware or a software tag variable whose value indicates the status of a common resource. Its purpose is to lock the resource being used. A process which needs the resource will check the semaphore for determining the status of the resource followed by the decision for proceeding. In multitasking operating systems, the activities are synchronized by using the semaphore techniques.

Meaning of mutex - Binary semaphore vs. Mutex
Operating System mutex - A mutex and the binary semaphore are essentially the same. Both can take values: 0 or 1. However, there is a significant difference...
What are the different types of memory?
Operating System memory types - Cache Memory - This is a small amounts of memory used to speed up system performance.....
Operating System virtual memory - Explain the meaning of virtual memory.
Operating System virtual memory - Virtual memory is an approach to make use of the secondary storage devices as an extension of the primary storage of the computer......
Post your comment
Discussion Board
0s
good & understandble for every studnt
tejaswi 10-1-2015
Use of Semaphore
Semaphore very use full, Specially Binary semaphores.
Mehdi 12-15-2013
comment
It s very usefulll....
sathish 10-3-2013
BCA
definition good.
explain semaphore with example
vipul 05-1-2013
feedback
short answer is good but long is not sufficient , can you explain briefly
manohar 04-30-2013
semaphores
Good explanation
palanisamy 04-24-2013
Semaphore assignment
I enjoy the respound to my question
Dennis 03-4-2013
semaphore
what is function of semaphore....
ranjit kumar 02-11-2013
Semaphore and Mutex
If you want generic understanding of semaphore and mutex you can check the video

http://www.youtube.com/watch?v=VQFJQJGmixM

It explains it in a basic way.
Vijay 01-21-2013
computer
good
sreeniga 11-17-2012
o/s
i understand. vvvv good
shabir 07-15-2012
hello
good explanation.
preeti 06-8-2012