# # semaphore
APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

2003/09/26 semaphore

I've removed advertising from most of this site and will eventually clean up the few pages where it remains.

While not terribly expensive to maintain, this does cost me something. If I don't get enough donations to cover that expense, I will be shutting the site down in early 2020.

If you found something useful today, please consider a small donation.



Some material is very old and may be incorrect today

© September 2003 Tony Lawrence

In the computer world, a semaphore controls access to a resource or resources that need to be shared by multiple processes. This is particularly important in the kernel where interrupt routines have to be careful about kernel structures other processes may be modifying, and when multiple CPU's are used (SMP).

A semaphore can be binary or otherwise (binary means that if it is in use, nothing else should use it); non binary versions are used where there is more than one of whatever it is we are sharing, but there is some limit.

The general rule for acquiring a semaphore is that if its value is 0, the process sleeps until it isn't. If it is not, the semaphore is decremented and the process has access to whatever the semaphore is protecting.

Whether binary or not, the important implementation detail is that testing and decrementing has to be "atomic"; that is, no other process can sneak in while those actions are taking place.

Ordinary user programs sometimes have need of such things too.


If you found something useful today, please consider a small donation.



Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

->
-> semaphore


Inexpensive and informative Apple related e-books:

Take Control of High Sierra

Photos: A Take Control Crash Course

Take control of Apple TV, Second Edition

Take Control of the Mac Command Line with Terminal, Second Edition

Sierra: A Take Control Crash Course





More Articles by © Tony Lawrence





Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us


Printer Friendly Version





Today’s computers are not even close to a 4-year-old human in their ability to see, talk, move, or use common sense. One reason, of course, is sheer computing power. It has been estimated that the information processing capacity of even the most powerful supercomputer is equal to the nervous system of a snail—a tiny fraction of the power available to the supercomputer inside [our] skull. (Steven Pinker)




Linux posts

Troubleshooting posts


This post tagged:

Kernel

Linux

Programming

UnixWords



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode