Serialize access to (runtime thread) internals.
Multiple processors may use the thread system simultaneously, so
procedures that modify its data structures (or that just want to read
consistent data structures!) must arrange to serialize their accesses.
They must lock an OS-level mutex and unlock it when they are done, all
without-interrupts. While the mutex is locked, they should NOT signal
errors nor invoke arbitrary hooks, handlers, etc. Thus there should
be no need for a recursive mutex.
The nonrecursive mutex's atomic sections are implemented in uni-
processing worlds by masking all interrupts. Inside, a LOCKED? flag
is set and cleared and asserts check that the thread system is locked
(or not!). Allowing GC interrupts in these sections is left as an
exercise.
The channel-close and process-delete primitives are called inside the
thread system's atomic deregistration operations to ensure that the
timer interrupt or wait-for-io (i.e. test-select-registry called on
another processor) do not use the invalid descriptors.