开发者

What situations can PHP semaphore be applied to?

开发者 https://www.devze.com 2023-01-18 18:19 出处:网络
开发者_如何学运维I am wondering what would be a good situation to utilize semaphore in PHP or in general, trying to expand my horizons.Semaphores are very close to the core of every Operating System.
开发者_如何学运维

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


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

Semaphores and concurrent programming

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

Hope that helps,

0

精彩评论

暂无评论...
验证码 换一张
取 消