Interrupted library calls

Casey Leedom casey at gauss.llnl.gov
Fri Jan 19 10:13:50 AEST 1990


| From: paul at mecazh.UUCP (Paul Breslaw)
| 
| [Mentions three possibilities to deal with interrupted library calls
| leaving corrupted data structures, etc. behind when the signal catching
| routine decides to head off elsewhere's via a longjmp(3).]

  You missed a couple of possibilities Paul.  Barry Margolin mentions one
which is by far the best [in my mind], but would require:

    1.	The addition on an ``unwind-protect'' code pointer to the C stack
	frame.

    2.	Modification of the C function entry and exit code to allocate
	and initialize the unwind-protect pointer to NULL on entry and
	execute the pointed to code if the unwind-protect pointer is
	non-NULL on exit.

    3.	A mechanism to manipulate this pointer (probably just a couple of
	macros.)

    4.	A change in the semantics of longjmp(3) to indicate that it calls
	each of the non-NULL unwind-protect code segments as it unwinds
	the stack

Perhaps Barry will explain what happens when an interrupt happens while
unwind-protect code is being executed ...  The issue of what happens with
respect to inlined functions is also interesting.  Perhaps the presence of
unwind-protect pointer manipulation should simply prevent a function from
being inlined ...

  Another possibility which is perhaps a little more practical, given the
inertia of language standards, is to implement the above outside of the
regular C stack by providing a separate unwind-protect stack and routines
to manipulate it.  This would require large amounts of standardization
effort and recoding to use it, but wouldn't require changing anything in
the ANSI C standard.

  On a final note, work is now being done to look into the possibility of
moving most of the signal facilities into user space.  This would
essentially reduce the expence of calling setsigvec, sigblock, etc. to a
function call instead of a system call.  The penalty would be that *all*
signals would be delivered from the kernel to the signal dispatcher in
user space even if they were blocked or ignored.  It's expected that
overall this should be a major win for most applications.  If it is
implemented, then the thought of putting signal blocking around critical
sections in library routines isn't cause for quite so much queasiness ..

Casey



More information about the Comp.unix.wizards mailing list