Next: Implementation (Linux x86), Previous: Waitqueue/condition variables, Up: Threading
If the user has multiple views onto the same Lisp image (for example,
using multiple terminals, or a windowing system, or network access)
they are typically set up as multiple sessions such that each
view has its own collection of foreground/background/stopped threads.
A thread which wishes to create a new session can use
sb-thread:with-new-session
to remove itself from the current
session (which it shares with its parent and siblings) and create a
fresh one.
# See also sb-thread:make-listener-thread
.
Within a single session, threads arbitrate between themselves for the
user's attention. A thread may be in one of three notional states:
foreground, background, or stopped. When a background process
attempts to print a repl prompt or to enter the debugger, it will stop
and print a message saying that it has stopped. The user at his
leisure may switch to that thread to find out what it needs. If a
background thread enters the debugger, selecting any restart will put
it back into the background before it resumes. Arbitration for the
input stream is managed by calls to sb-thread:get-foreground
(which may block) and sb-thread:release-foreground
.
sb-ext:quit
terminates all threads in the current session, but
leaves other sessions running.