gomp-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gomp-discuss] Decision about semaphores ..


From: Lars Segerlund
Subject: Re: [Gomp-discuss] Decision about semaphores ..
Date: Wed, 19 Feb 2003 12:24:20 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.2.1) Gecko/20021226 Debian/1.2.1-9


I have looked at libc's semaphores, but it's explicitly stated that they are not SMP safe ! ( even a bit unsure about how they would work with native linux threads ).

You use a semaphore for a join in the following fashion, every thread which is started increases the value of the semaphore ( starts an 0 ), when theyre finished they atomically decrease it, and the thread which sets it to null uses a signal to signal the join. ( also works for barriers and synchronisation ).

Threads which have decreased the semaphore waits on the signal, and the main thread can do the same.

I was thinking of using a condition ( cond ) in the threading lib, which is easy to wait on ( not busy, so sleep on would be more appropriate ).

/ Lars Segerlund.

Pop Sébastian wrote:
On Wed, Feb 19, 2003 at 11:08:25AM +0100, Steven Bosscher wrote:

Would you mind explaining to the not-a-computer-scientist here what a
semaphore is? :-)



From "info libc" section "POSIX Semaphores":

   Semaphores are counters for resources shared between threads. The
basic operations on semaphores are: increment the counter atomically,
and wait until the counter is non-null and decrement it atomically.



_______________________________________________
Gomp-discuss mailing list
address@hidden
http://mail.nongnu.org/mailman/listinfo/gomp-discuss






reply via email to

[Prev in Thread] Current Thread [Next in Thread]