[483] in Pthreads mailing list archive

home help back first fref pref prev next nref lref last post

New Pthreads Book

daemon@ATHENA.MIT.EDU (Chris Colohan)
Tue Nov 5 03:39:53 1996

From: Chris Colohan <colohan@eecg.toronto.edu>
To: pthreads@MIT.EDU
Date: 	Mon, 4 Nov 1996 17:50:53 -0500

I just picked up a copy of a new book last week, "Pthreads
Programming" by Bradford Nichols, Dick Buttlar and Jacqueline Proulx
Farrell (O'Reilly & Associates, ISBN 1-56592-115-1).

Anyways, in case no one else has seen it, I would like to reccomend it
as an excellent source of information about how Pthreads work and how
to write Pthreads programs.  Having said that, I was wondering how
applicable it is to MIT-Pthreads?

The book claims to cover Posix 1003.1c -- is this the same version of
the standard that MIT-Pthreads is coded to?  Is it reasonable for me
to expect Pthreads to behave in the same manner as outlined in this
book, especially when it comes to signal handling etc?

If so, I have found a couple of small (trivial) bugs in Pthreads:
- The structure element sched_param.prio should be named
sched_param.sched_priority.
- The functions sched_get_priority_max() and sched_get_priority_min()
seem to be missing...

In addition, this book answered an earlier question I had that wansn't
answered on this mailing list -- How to call pthreads functions in a
signal handler.  The short answer is:  you can't.  The long answer is:

- Block the signal on all threads.
- Create a very high priority signal handling thread that is of the
following format:
while(1) {
    sigwait(&my_sigmask, &caught);
    handle the signal...
}

This should behave almost identically to a signal handler.  The
differences I can see are:
a)  It may respond a wee bit slower than a real signal handler.
b) No context is passed to the signal handler on the stack.  So if I
trap SIGSEGV, I can't unwind the stack and figure out what instruction
caused the fault, or what page was faulted on.  This is only a problem
for geeks like me, who are trying to do the equivalent of my own page
faulting handler...

Chris Colohan
Computer Engineering, University of Toronto

home help back first fref pref prev next nref lref last post