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 13:00:00 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.2.1) Gecko/20021226 Debian/1.2.1-9


 Yes I have looked at it :-) .

 I have a downloaded copy of it also, it's very good.

 / Lars.

Steven Bosscher wrote:
Op wo 19-02-2003, om 12:24 schreef Lars Segerlund:

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.


Have you looked at: http://www.advancedlinuxprogramming.com/ ?

IIRC they discuss lots of threaded programming issues.  The book is
free.

Greetz
Steven





_______________________________________________
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]