Find the answer to your Linux question:
Results 1 to 2 of 2
PHP use packages by 3 semaphores (on C++ you can use any package) the first one is a general semaphore. It can be locked or unlocked. the second one is ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2006
    Posts
    3

    Unix System V semaphore in PHP & C++


    PHP use packages by 3 semaphores (on C++ you can use any package)

    the first one is a general semaphore. It can be locked or unlocked.

    the second one is a counter. it is incmented when new proccess get the semaphore ID, and decremented when this proccess release ID.

    what is the third semaphore for???
    who knows?

    if the semaphore creator program set 0 to the 3 semaphore. this semaphore will be 0 all the time.

    but if this semaphore set to 1 by first program, then it work like counter (like 2 semaphore)???

    how it is used?

  2. #2
    Linux User
    Join Date
    Aug 2005
    Location
    Italy
    Posts
    401
    What I know about semphores, they are counters with two operation associated: up and down.

    These operations permits to increment and decrement semphore value. Decrease will block if semphore is zero (until an up is executed). The peculiarity is that up and down are atomical: they cannot be interrupt while they do they work (wich is a considerable caracteristich in a multitask system).

    Stop.

    Other semphores types are implementation dependent, but as far I can see they are based on this idea. Maybe someone can simplify things using mutex, wich is a sempahore wich can take value of 0 or 1 (blocked and unblocked): mutex are sempahores.

    There also barriers, wich is mechanisme to synchronize different execution threads: when a execution thread reachs the barrier, it will block, until all execution threads are blocked on barrier... i don't know how this is implemented, but I think everyone could implement this using sempahores.

    ----

    This is what I know about semphores, but I don't understand what kind of semphores you are talking about.
    When using Windows, have you ever told "Ehi... do your business?"
    Linux user #396597 (http://counter.li.org)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •