[H-GEN] pthreads

Raymond Smith raymonds at uq.net.au
Thu Aug 26 02:43:57 EDT 1999


[ Humbug *General* list - semi-serious discussions about Humbug and
Unix-related topics. ]

On Thu, 26 Aug 1999, Byron Ellacott wrote a most excellent discussion on
concurrent programming:
> You can then have multiple threads wait on that condition variable, and the 
> expected behaviour will happen.  Note, however, that this introduces a busy 
> loop that is quite probably unnecessary, in that signals are a poor-mans 
> threading, usually used to avoid blocking on an exec()/wait() or to set an 
> alarm, and so on.  In a threaded world[1], one would create a thread that 
> blocks on the result, and avoid the ugly signal issue.

F'eh! Threads be damned; give me my heavyweight process any day. :-)

I'd take issue with the idea of signals being "a poor mans threads". They
are fundamentally a specialised form of inter-process communication.
While you may use them with processes to program concurrently, and indeed
may have to if you are without threads, this is not what they are for.

Signals exist primarily so the OS can interrupt a process with urgent
information. Remember that UNIX programs are not event driven, UNIX
programs drive the system.

Another purpose is to allow related processes to communicate significant
events (usually death) to other related process. Yet another use is as
the primary mechanism UNIX users have to control their processes.

Cheers,

Raymond

---
raymond at humbug.org.au              The early bird catches the worm, 
                                       but the second mouse eats the cheese




--
This is list (humbug) general handled by majordomo at lists.humbug.org.au .
Postings only from subscribed addresses of lists general or general-post.



More information about the General mailing list