emacs.d/clones/www.sbcl.org/sbcl-internals/The-deferral-mechanism.html

82 lines
3.5 KiB
HTML
Raw Normal View History

2023-01-18 20:30:47 +01:00
<html lang="en">
<head>
<title>The deferral mechanism - SBCL Internals</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="SBCL Internals">
<meta name="generator" content="makeinfo 4.11">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Signal-handling.html#Signal-handling" title="Signal handling">
<link rel="prev" href="Groups-of-signals.html#Groups-of-signals" title="Groups of signals">
<link rel="next" href="Implementation-warts.html#Implementation-warts" title="Implementation warts">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This manual is part of the SBCL software system. See the `README'
file for more information.
This manual is in the public domain and is provided with
absolutely no warranty. See the `COPYING' and `CREDITS' files for
more information.
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<p>
<a name="The-deferral-mechanism"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="Implementation-warts.html#Implementation-warts">Implementation warts</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Groups-of-signals.html#Groups-of-signals">Groups of signals</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Signal-handling.html#Signal-handling">Signal handling</a>
<hr>
</div>
<h3 class="section">6.2 The deferral mechanism</h3>
<h4 class="subsection">6.2.1 Pseudo atomic sections</h4>
<p>Some operations, such as allocation, consist of several steps and
temporarily break for instance gc invariants. Interrupting said
operations is therefore dangerous to one's health. Blocking the
signals for each allocation is out of question as the overhead of the
two <code>sigsetmask</code> system calls would be enormous. Instead, pseudo
atomic sections are implemented with a simple flag.
<p>When a deferrable signal is delivered to a thread within a pseudo
atomic section the pseudo-atomic-interrupted flag is set, the signal
and its context are stored, and all deferrable signals blocked. This
is to guarantee that there is at most one pending handler in
SBCL. While the signals are blocked, the responsibilty of keeping
track of other pending signals lies with the OS.
<p>On leaving the pseudo atomic section, the pending handler is run and
the signals are unblocked.
<h4 class="subsection">6.2.2 <code>WITHOUT-INTERRUPTS</code></h4>
<p>Similar to pseudo atomic, <code>WITHOUT-INTERRUPTS</code> defers deferrable
signals in its thread until the end of its body, provided it is not
nested in another <code>WITHOUT-INTERRUPTS</code>.
<p>Not so frequently used as pseudo atomic, <code>WITHOUT-INTERRUPTS</code>
benefits less from the deferral mechanism.
<h4 class="subsection">6.2.3 Stop the world</h4>
<p>Something of a special case, a signal that is blockable but not
deferrable by <code>WITHOUT-INTERRUPTS</code> is <code>SIG_STOP_FOR_GC</code>. It
is deferred by pseudo atomic and <code>WITHOUT-GCING</code>.
</body></html>