Boost logo

Boost Users :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-02-18 10:15:58


Craig Rodrigues wrote:

> OK, well I don't do much Windows programming, so I don't
> really understand what event variables are. I'll have to do
> my homework and read up on them.
>
> In terms of explaining what a semaphore is,
> my frame of reference is the stuff in POSIX:
>
> http://www.opengroup.org/onlinepubs/007904975/functions/sem_post.html
> http://www.opengroup.org/onlinepubs/007904975/functions/sem_wait.html
> http://www.opengroup.org/onlinepubs/007904975/functions/sem_trywait.html
> http://www.opengroup.org/onlinepubs/007904975/functions/sem_timedwait.html
>
> Basically, a semaphore is initialized with a count.
> When you call sem_post(), the semaphore count is incremented.
> When you call sem_wait(), if the semaphore count is 0, then the
> thread blocks, else the semaphore count is decremented.

The interesting part of "POSIX on semaphores" is in

    http://tinyurl.com/2s89

Look the the phrase "Much experience with semaphores shows" and futher
paragraphs. In essense, it's says that semaphores are for signal handlers
and for inter-process synchronization and discourages their use anywhere
else.

- Volodya


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net