What is a semaphore?

A hardware or software flag.
In multitasking systems, a semaphore is a variable with a value that indicates the status of a common resource.
Its used to lock the resource that is being used.
A process needing the resource checks the semaphore to determine the resource's status
and then decides how to proceed.

In programming, especially in UNIX systems, semaphores are a technique for coordinating or synchronizing activities
in which multiple process compete for the same operating system resources.
A semaphore is a value in a designated place in operating system (or kernel) storage that each process can check and then change.
Depending on the value that is found, the process can use the resource or will find that it is already in use and must wait for some period before trying again.
Semaphones can be binary (0 or 1) or can have additional values.
Typically, a process using semaphores checks the value and then, if it using the resource, changes the value to reflect this so that subsequent semaphore users will know to wait.
Semaphores are commonly use for two purposes: to share a common memory space and to share access to files.
Semaphores are one of the techniques for interprocess communication (interprocess communication).
The C programming language provides a set of interfaces or "functions" for managing semaphores.

Have a Unix Problem
Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.