What is a semaphore in the context of programming?

dvarian

I overheard a conversation today where two programmers were talking and one used the term “semaphore.” The only way I’ve ever heard the work semaphore used was in a nautical context, where it means naval flag signals. What does it mean in a programming context?

Answer this Question

Answers

2 total
jimlynch
Vote Up (2)

Semaphore (programming)
https://en.wikipedia.org/wiki/Semaphore_(programming)

"In computer science, particularly in operating systems, a semaphore is a variable or abstract data type that is used for controlling access, by multiple processes, to a common resource in a parallel programming or a multi user environment.

A useful way to think of a semaphore is as a record of how many units of a particular resource are available, coupled with operations to safely (i.e., without race conditions) adjust that record as units are required or become free, and, if necessary, wait until a unit of the resource becomes available. Semaphores are a useful tool in the prevention of race conditions; however, their use is by no means a guarantee that a program is free from these problems. Semaphores which allow an arbitrary resource count are called counting semaphores, while semaphores which are restricted to the values 0 and 1 (or locked/unlocked, unavailable/available) are called binary semaphores."

bcastle
Vote Up (1)

It concerns thread management. To quote Wikipedia, a semaphore is “a variable or abstract data type that is used for controlling access, by multiple processes, to a common resource in a parallel programming or a multi user environment.”

Ask a question

Join Now or Sign In to ask a question.
Wyvern securely rolls five programming languages into one.
The latest rankings of programming languages show a landscape that’s increasingly fragmented, but still dominated by the old guard
In the competition for developer talent, offering a good cup of joe could give your company an edge
I’ve said it all along that battery life was going to make or break this smart watch. Now that the Moto 360 is finally here, my fears have been confirmed.
Apple has added a list of rules about how developers can use HealthKit, HomeKit, and keyboard data.
App Store rejections may not be the hot-button issue it was a few years ago, but for developers, it's still a chief area of concern. To give app makers a little clarity and direction, Apple published a new page to its Developer site that outlines some of the most common reasons an app gets rejected from the App Store.
A new study of open source project growth suggests that choosing a permissive license can help your community to grow faster
Wishing your Raspberry Pi had more power for all those hardware hacking projects you have planned? There's a new barebones board on the market that may better fit your needs, and right now you can sign-up for your chance to get it for free.
Use your coding powers to raise money for a worthy cause, no ice water involved
A new analysis of Reddit comments shows which language’s developers seem to be the happiest - and which are the most foul-mouthed
Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

randomness