tags:

views:

71

answers:

1

I am wondering what would be a good situation to utilize semaphore in PHP or in general, trying to expand my horizons.

+1  A: 

Semaphores are very close to the core of every Operating System. When you want to use concurrency they are a valuable tool. They control, as in traffic, the access of multiple "consumers" to the same "resources".

For example, suppose you want to write to a log file from different applications, you could use an application that, using semaphores, stop or allows another one to write into that file. So every app would poll the "semaphore" app first, and, if it is allowed, then write to the file.

If you want more information/examples, please look here:

http://www.experiencefestival.com/semaphore_programming_-_c_semaphore

http://stackoverflow.com/questions/3848063/semaphores-and-concurrent-programming

http://programmingexamples.wikidot.com/java-semaphore

Hope that helps,

Ramon Araujo