Thread: Can i change value of a named semaphore?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    http://en.wikipedia.org/wiki/Semaphore_(programming)
    http://www.tin.org/bin/man.cgi?section=3&topic=sem_init
    You initialise the semaphore to some N
    You're allowed to call sem_wait() N times in succession before blocking.
    At some point, there will be N sem_post() calls to return the semaphore to it's initial state.

    Are you saying you want to change N after you've created it?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  2. #2
    Registered User
    Join Date
    Oct 2008
    Posts
    35
    yes, what i want is to have the semaphore locked, and then change the value to N, being N the number of children, so that all of them start accessing the memory.

    Seems i will have to use N sem_post. not in one instruction how i hoped, but it works

    Thank You all

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 04-19-2008, 12:06 AM
  2. how to change static char* and not lose mem ?
    By jabka in forum C Programming
    Replies: 15
    Last Post: 09-07-2007, 05:33 PM
  3. Change Value in an array
    By beginner999 in forum C Programming
    Replies: 3
    Last Post: 01-18-2003, 07:16 AM
  4. Replies: 2
    Last Post: 11-08-2002, 03:22 AM
  5. Replies: 2
    Last Post: 09-04-2001, 02:12 PM