Thread: semaphore

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    2
    Rep Power
    0
    I have to block, for an exclusive use, a part of code or a function.
    How can I make it with PHP and what is 'key' parameter for 'sem_get'?
    I have to recompile PHP? and witch options I have to use?
    Thank in advances.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Rotterdam, the Netherlands
    Posts
    1
    Rep Power
    0
    You will need something along these lines:

    $i = sem_get("NAME");
    sem_acquire($i)

    // pout your code here

    sem_release($i);

    The NAME is a string you can come up with yourself. The system gives back a number which you have to use in the semaphore.

    The thing I'm not certain about is the behaviour of sem_acquire. Does it block when not getting the semaphore or does it return false and continue? Manual is not quite clear about that.

Similar Threads

  1. Perl semaphore example
    By gmathews in forum Perl Programming
    Replies: 3
    Last Post: April 5th, 2007, 06:24 PM
  2. Using semaphores to lock files
    By Coolblue3141 in forum C Programming
    Replies: 7
    Last Post: January 29th, 2004, 10:21 PM
  3. semaphore problem
    By paulr1984 in forum C Programming
    Replies: 6
    Last Post: January 27th, 2004, 07:59 AM
  4. making use of a semaphore
    By FDavid in forum UNIX Help
    Replies: 0
    Last Post: July 29th, 2003, 09:19 PM
  5. Semaphore and Shared Memory Functions
    By jbuckle24 in forum PHP Development
    Replies: 0
    Last Post: August 29th, 2001, 02:49 PM

IMN logo majestic logo threadwatch logo seochat tools logo