Find the answer to your Linux question:
Results 1 to 3 of 3
Dear All, I want to have some info on the following, 1)when one required to create set of semaphores to create a resource. int semop(int semid, struct sembuf *sops, unsigned ...
  1. #1
    Just Joined!
    Join Date
    May 2009
    Posts
    11

    Semaphore

    Dear All,

    I want to have some info on the following,

    1)when one required to create set of semaphores to create a resource.

    int semop(int semid, struct sembuf *sops, unsigned nsops);

    in the above sys call when we need to have more than one semaphore.

    2) what are the different dependencies that semaphore with respect to the
    sem_op value------>this is more confusing me.

    If possible please provide some good example to study.

    Regards,
    Sri Anu.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Your question is totally unclear to me! Semaphores are basically global counters. You can test/increment/decrement them in an atomic manner, knowing that the OS will not allow two processes or threads to do so at the same time. Other than that, the function calls to create/register/use them are all well documented in the Linux man pages.

    Why do you say that the semop() call needs more than one semaphore? The sops argument is a pointer is the address of the array of semaphore operations to perform, and the nsops variable indicates how many entries are in the array. This can be one or more. Read the semop man page for more information.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    May 2009
    Posts
    11

    Semaphore

    Dear Friend,

    I read Manual page regarding semaphore,I know we can have an array of semaphores.Like using semget(),we can specify how many semaphores(array).
    but what my question is how to synchronize a resource using array of semaphore
    (set of semaphore),because all semaphore within a set will be having same SEM_ID.
    Instead of that we can go for different semaphores with different SEM_ID.

    If possible,Please provide some example programs to understand the concept above and SEMOP system call.

    Regards,
    Sri Anu.

Posting Permissions

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