I'm porting a piece of software from our school's Sequent Dynix
(a BSD-style OS) to Linux. This software relies fairly heavily
on signals, but apparently the semantics of signals differs
between Dynix and Linux.
The problem is that the software uses signals to implement a
threads-style abstraction with preemption, i.e. setitimer() is
used to set up a SIGVTALRM every so often, then a longjmp() is
done to move to a different thread. Under Dynix, the new thread
will be preempted and the signal handler called when the SIGVTALRM
is generated again by the timer.
Linux, however, is a different story. Under Linux, the signal
is blocked until the signal handler returns, and thus the thread
that "takes over" will run until completion or until it
voluntarily yields (i.e. longjmp()s back to the thread that was
running in the signal handler, which returns from the handler).
I have tried:
1) Compiling with -I/usr/include/bsd & -D__FAVOR_BSD
2) Linking with -lbsd
3) Turning off the SA_ONESHOT flag in the sa_flags structure
4) Most combinations of (1)-(3) above.
a) Is there another flag in sa_flags to set to emulate Dynix'
(BSD-ish) signals? Or compile flags or libraries to try?
b) Is there any information about how signal handling and
delivery in Linux work? I poked around in the kernel for
a while, but didn't make much headway.
c) Do you have any other suggestions for BSD-like nonblocking
Many thanks. I'll summarize any answers I get (via posting or
email) to the net.
- Don (not speaking for UA)