Matt Birkholz [Sun, 19 Jul 2015 19:51:17 +0000 (12:51 -0700)]
Make wind.o state thread-local.
Matt Birkholz [Sat, 25 Jul 2015 21:48:52 +0000 (14:48 -0700)]
Make uxterm.o state thread-local.
Make the static slave_name buffer auto. Use ptsname_r instead of
ptsname. (terminal_table et al are already used serially because of
the runtime system's use of the open-channels gc-finalizer.)
Matt Birkholz [Sun, 19 Jul 2015 20:58:50 +0000 (13:58 -0700)]
Make uxsock.o state thread-local.
Make the storage class of "address" auto.
Matt Birkholz [Sun, 19 Jul 2015 20:56:10 +0000 (13:56 -0700)]
Make uxsig.o state thread-local.
Most of this module's variables are read-only after initialization.
Make blocked_signals and buffer thread-local.
Matt Birkholz [Sun, 19 Jul 2015 20:46:27 +0000 (13:46 -0700)]
Make uxproc.o state thread-local or single-threaded.
Make grabbed_signal_mask pthread-local. (process_table et al are
already used serially by the runtime system.)
Matt Birkholz [Tue, 21 Jul 2015 07:46:11 +0000 (00:46 -0700)]
Make uxenv.o state single-threaded.
Serialize use of the process's current working directory.
The top-level REPL no longer munges the cwd. The only use of the
SET-WORKING-DIRECTORY-PATHNAME! primitive is serially, with a thread
mutex lock, in a dynamic-wind.
Matt Birkholz [Sun, 19 Jul 2015 19:49:26 +0000 (12:49 -0700)]
Make utils.o state thread-local.
Matt Birkholz [Sat, 20 Dec 2014 19:08:15 +0000 (12:08 -0700)]
Make storage.o state thread-local or single-threaded.
Make the debugging flags and buffers pthread-local.
Serialize use of the MAKE-EPHEMERON primitive with a pthread mutex.
fixed_objects and heap_reserved are modified by primitives that the
runtime system already uses in serial fashion.
Matt Birkholz [Sun, 19 Jul 2015 21:46:34 +0000 (14:46 -0700)]
Make pruxffi.o state thread-local.
Declare cstach_depth thread-local. The primitive caches might be
filled multiple times concurrently but they are read and written
atomically, so no harm done.
Matt Birkholz [Sun, 19 Jul 2015 19:22:41 +0000 (12:22 -0700)]
Make primutl.o single-threaded.
Most of this module's variables are modified, after initialization, by
declare_primitive_internal or find_primitive_cname. Serialize the
former and eliminate the hack in the latter.
Matt Birkholz [Sun, 19 Jul 2015 19:17:10 +0000 (12:17 -0700)]
Make ostty.o state thread-local.
The next_interrupt_char is set by the processor's signal handler and
read by Scheme's interrupt handler, which now runs with timer
interrupts masked (to keep the handler on the processor with the
next_interrupt_char).
Matt Birkholz [Tue, 21 Jul 2015 07:38:38 +0000 (00:38 -0700)]
Make obstack.o state thread-local.
Matt Birkholz [Sun, 19 Jul 2015 18:40:19 +0000 (11:40 -0700)]
Make intern.o state single-threaded.
Serialize operations on the obarray using a pthread mutex. Drop the
mutex while consing the symbol's entry.
Matt Birkholz [Thu, 23 Jul 2015 00:46:04 +0000 (17:46 -0700)]
Make fasload.o state single-threaded.
Matt Birkholz [Tue, 21 Jul 2015 07:35:11 +0000 (00:35 -0700)]
Make error.o state thread-local.
Matt Birkholz [Tue, 21 Jul 2015 07:34:38 +0000 (00:34 -0700)]
Make comutl.o state thread-local.
Matt Birkholz [Sun, 19 Jul 2015 21:51:12 +0000 (14:51 -0700)]
Make cmpint.o state thread-local.
Make linking_cc_block_p thread-local. The rest of this module's
variables are initialized by the ASM_INIT_HOOK, part of
compiler_reset, which is called during compiler_initialize (the
singularly threaded boot) or LOAD-BAND (a GC wait).
Matt Birkholz [Sun, 19 Jul 2015 17:39:56 +0000 (10:39 -0700)]
Make bkpt.o state thread-local.
Matt Birkholz [Fri, 5 Dec 2014 00:12:57 +0000 (17:12 -0700)]
Make avltree.o state thread-local.
Matt Birkholz [Sun, 19 Jul 2015 17:31:14 +0000 (10:31 -0700)]
Forward SIGCHLD to the io-waiter.
Set/clear the new variable smp_io_blocked around calls to poll/select
so that subprocess_death (SIGCHLD) can wake a blocked processor
without having to ask Scheme which (if any) is running the io-waiter.
Wake the processor with a timer interrupt withOUT fiddling next_timer.
Matt Birkholz [Sun, 19 Jul 2015 16:03:07 +0000 (09:03 -0700)]
Add SIGALRM distributor.
Matt Birkholz [Thu, 23 Jul 2015 22:36:19 +0000 (15:36 -0700)]
Add mutex LOCK/UNLOCK boilerplate.
Matt Birkholz [Tue, 21 Jul 2015 07:27:11 +0000 (00:27 -0700)]
Add i386 assembly to allocate and access thread-local variables.
Matt Birkholz [Sun, 19 Jul 2015 05:55:44 +0000 (22:55 -0700)]
Add x86_64 assembly to allocate and access thread-local variables.
Thus stack_pointer, Free and Registers are now thread-local. And
several more variables are allocated in the assembly (no longer in the
C code): heap_alloc_limit, heap_end, stack_guard, stack_start,
C_Stack_Pointer and C_Frame_Pointer.
Matt Birkholz [Sun, 19 Jul 2015 05:47:38 +0000 (22:47 -0700)]
Initialize thread-local compiler_utilities.
Split the thread-local parts of compiler_initialize into
compiler_initialize_processor, those of compiler_reset into
compiler_reset_processor. Split the non-thread-local parts of
ASM_RESET_HOOK into ASM_INIT_HOOK. Call the _processor versions in
co-processor startup and after GC waits (when necessary).
Add compiler_reset_p flag to processor_t so that load-band
(compiler_reset) can notify the other processors to load the new
compiler_utilities into their Registers slots.
Matt Birkholz [Sun, 19 Jul 2015 01:20:31 +0000 (18:20 -0700)]
Make the svm1 interpreter's state thread-local.
Matt Birkholz [Tue, 21 Jul 2015 09:11:12 +0000 (02:11 -0700)]
Make trap_state and current_interruptable_extent thread-local.
Split the thread-local parts of UX_initialize_trap_recovery into
UX_initialize_trap_state, and those of OS_initialize into
OS_initialize_processor. Call the latter in OS_initialize and the
co-processors' work function.
Matt Birkholz [Sat, 25 Jul 2015 21:48:11 +0000 (14:48 -0700)]
Make the interpreter's state thread-local.
Pull the initialization of the affected variables into a new
initialize_processor_early function and call it in both main and the
co-processors' "work" function.
Still, stack_pointer, Free and Registers are not yet thread-local.
Such declarations would be in conflict with the x86_64 assembly code.
Matt Birkholz [Tue, 18 Aug 2015 16:35:16 +0000 (09:35 -0700)]
Synchronize initialized processors.
The main pthread must wait for the other processors to be initialized,
else the first smp-gc-lock waits forever for processors that cleared
their global-gc interrupt while initializing.
Matt Birkholz [Sat, 18 Jul 2015 23:59:37 +0000 (16:59 -0700)]
Add io-waiter-registry, a copy of io-registry.
The io-waiter will apply test-select-registry to this copy while other
threads modify the original.
Matt Birkholz [Sat, 18 Jul 2015 23:37:19 +0000 (16:37 -0700)]
Add copy-select-registry!.
Matt Birkholz [Sat, 18 Jul 2015 23:32:41 +0000 (16:32 -0700)]
Add COPY-SELECT-REGISTRY primitive.
Matt Birkholz [Sat, 18 Jul 2015 23:04:44 +0000 (16:04 -0700)]
Add io-waiter, the *one* processor that waits on the io-registry.
The other processors use the new SMP-IDLE primitive to wait for
runnable threads. Wake one of these whenever threads become runnable.
Wake the io-waiter whenever the io-registry is changed.
Matt Birkholz [Tue, 21 Jul 2015 08:14:58 +0000 (01:14 -0700)]
Add SMP-IDLE primitive.
Matt Birkholz [Wed, 15 Jul 2015 10:16:58 +0000 (03:16 -0700)]
Add an ignore_status_change parameter to OS_pause for SMP-IDLE.
OS_pause previously returned immediately if there were pending
interrupts OR subprocess status changes, as required by a blocking
test-select-registry primitive. That made it useless to the SMP-IDLE
primitive, which spins in the idle loop until the io-waiter (or a
timer interrupt handler) gets around to syncing subprocess statuses.
It will spin too after getting a SIGCHLD until statuses are synced.
Matt Birkholz [Tue, 21 Jul 2015 20:13:06 +0000 (13:13 -0700)]
Add SMP-WAKE primitive.
Matt Birkholz [Fri, 24 Jul 2015 00:54:30 +0000 (17:54 -0700)]
Fix test-select-registry to "atomically" unmask interrupts.
When SMPing the machine cannot miss e.g a global-GC interrupt, else
the whole world grinds to a halt. Using (set-interrupt-enables!
interrupt-mask/all) and then (test-select-registry ... #t) admits a
small "hole" wherein such an interrupt can drop, allowing the machine
to block without realizing it missed an interrupt intended to wake it.
The test-select-registry primitive does not actually "atomically
unmask interrupts" but simply ignores the mask inside its critical
section -- as if the mask was interrupt-mask/all.
Adjust branches so that, when not blocking, the simpler poll/select is
called (rather than ppoll/pselect).
Eliminate loops that re-try after masked interrupts arrive since all
interrupts are considered unmasked here.
Conflicts:
src/runtime/thread.scm
Matt Birkholz [Thu, 23 Jul 2015 23:25:01 +0000 (16:25 -0700)]
Serialize the outf functions.
Matt Birkholz [Sat, 25 Jul 2015 21:46:13 +0000 (14:46 -0700)]
Punt gc_space_needed when SMPing. The local heap is empty after GC.
Matt Birkholz [Tue, 18 Aug 2015 16:29:12 +0000 (09:29 -0700)]
Add shared and local heaps.
Matt Birkholz [Tue, 18 Aug 2015 07:11:23 +0000 (00:11 -0700)]
Add SMP GC primitives and use them (with 1 processor).
Add SMP-GC-LOCK, SMP-GC-UNLOCK and SMP-GC-WAIT. Add a stub for the
remaining unimplemented SMP primitive: SMP-LOCK-OBARRAY. Make
SMP-COUNT return 1 so that the runtime system sets enable-smp? and
calls the new primitives.
Drop the threads_mutex (but keep threads_processor set) in SMP-GC-LOCK
so that processors waiting to enter the thread system (in
SMP-LOCK-THREADS) will wake, enter the GC-WAIT state, then try again.
Matt Birkholz [Tue, 18 Aug 2015 06:04:28 +0000 (23:04 -0700)]
Add new primitives SMP-COUNT, SMP-ID and SMP-LOCK-THREADS.
Add new thread local variable "self", a pointer to a processor_t
describing the current processor. Include the processor ID in
Do_Micro_Error messages.
Matt Birkholz [Sat, 25 Jul 2015 21:30:40 +0000 (14:30 -0700)]
Add configure option --enable-smp and new machine options.
Machine options: "--processors" and "--processor-heap" with
corresponding environment variables "MITSCHEME_PROCESSORS" and
"MITSCHEME_PROCESSOR_HEAP_SIZE".
Matt Birkholz [Tue, 18 Aug 2015 16:21:26 +0000 (09:21 -0700)]
Synchronize processors for GC, purify and fasdump.
Matt Birkholz [Tue, 18 Aug 2015 16:57:06 +0000 (09:57 -0700)]
Accommodate multiple processors.
Keep the threads running on each processor in a current-threads
vector. Change the running list into a runnable list: the threads
that are runnable but not currently running on a processor.
Matt Birkholz [Tue, 18 Aug 2015 01:38:24 +0000 (18:38 -0700)]
Serialize access to (runtime thread) internals.
Multiple processors may use the thread system simultaneously, so its
procedures and timer interrupt handler must arrange to serialize.
They must lock/unlock an OS-level mutex and run without interrupts.
While the mutex is locked, they must not signal errors and may not
invoke arbitrary hooks, handlers, etc. (The mutex is not recursive.)
Inside the mutex's atomic sections a LOCKED? flag is set. Asserts
check that the thread system is locked when necessary.
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.
Matt Birkholz [Wed, 8 Jul 2015 20:45:06 +0000 (13:45 -0700)]
Clobber fluid-let and the (runtime state-space) package.
UNimplement fluid-let using dynamic-wind as a backward compatibility
kludge. Subsystems still using fluid-let, e.g. LIAR, must not be run
in multiple threads simultaneously. Fluid-let no longer provides
thread-local storage.
Replace the uniprocessor-only Hanson/Lamping state-spaces with
Scheme48's multiprocessing-friendly dynamic-points in a new package
(runtime wind).
Replace the previously fluid-assigned bindings state-space:local and
(runtime dynamic)bindings with thread slots dynamic-point and dynamic-
environment. Lose the error handling in wait-for-io; it runs when
there is no current thread, thus no way to bind-condition-handler.
Matt Birkholz [Tue, 18 Aug 2015 00:19:15 +0000 (17:19 -0700)]
Add register-gc-event, deregister-gc-event, registered-gc-event.
Punt the hook/record-statistic! fluid. With-gc-notification now uses
dynamic-wind to register and deregister a GC thread event for the
current thread.
Do not use ANY fluid state (e.g. nearest-cmdl/port) during a GC. Use
the console-i/o-port in hook/gc-start and hook/gc-finish. GCs can
happen in the thread system when there is no current thread.
The fluid state IS defined during the GC thread events. At the start
of such events, signal a REPL abort if the heap is low.
Matt Birkholz [Tue, 21 Jul 2015 01:11:42 +0000 (18:11 -0700)]
Replace subprocess status ticks with thread events.
Without without-interrupts, ticks do not work. It is possible to
block even though a subprocess has changed state between the last
observation of the global status tick and the suspend. Passing the
observed tick to suspend-current-thread would allow it to check for
new ticks in the atomic section wherein it decides if the thread
should suspend, but replacing without-interrupts with with-thread-
events-blocked suggests a cleaner solution: subprocess thread events.
The new procedures register-subprocess-event and deregister-
subprocess-event are now used by Edwin. ANY main loop managing
subprocesses AND IO should be using register-subprocess-event along
with with-thread-events-blocked and suspend-current-thread to reliably
block for either in an SMPing world.
Block-on-io-descriptor now uses with-thread-events-blocked instead of
without-interrupts but it does NOT use register-subprocess-event AND
WILL NOT UNBLOCK WHEN A SUBPROCESS CHANGES STATUS.
Unfortunately this breaks Edwin on OS2 and Win32 where it is now
possible for Edwin to block for keyboard input without noticing that a
subprocess has exited. Edwin's main loop in these worlds needs to be
updated to use a "suspend loop" and register-subprocess-event even
though they do not actually multi-process.
Subprocess-wait now uses a suspend loop like the one in block-on-io-
descriptor rather than blocking for the rest of the thread's timeslice
in the process-wait primitive. Synchronous subprocess management now
uses this procedure instead of the curious subprocess-wait*, the only
remaining procedure using ticks.
Thus SUBPROCESS-GLOBAL-STATUS-TICK and SUBPROCESS-STATUS-TICK are
eliminated.
Matt Birkholz [Sat, 27 Jun 2015 22:24:45 +0000 (15:24 -0700)]
Reimplement permanently-register-io-thread-event for SMPability.
Remove permanent tentries (waiting thread entries) from
io-registrations. Replace them with an event wrapper that loops,
re-registering after the wrapped event finishes. The loop assumes IO
is being consumed during the event. If not, it may spin forever.
Remove the notion of registering for the "front" of the queue too.
The X graphics device must take care to de-register its IO event
before closing the display, else the thread system may apply test-
select-registry to a closed descriptor.
Matt Birkholz [Sun, 5 Jul 2015 16:21:17 +0000 (09:21 -0700)]
Do NOT use permanently-register-io-thread-event in Edwin.
Edwin does not consume the IO in the thread event. This worked in a
uni-processing world where another thread could consume the IO in
round-robin fashion, but in an SMPing world there is no way to know
when it is appropriate to signal another event. In a naive
implementation (without special handling of these events), an idle
processor would spin, queuing MANY "IO ready" events to one thread
until another thread consumed the IO.
Edwin's X11 and console display types now block for IO on multiple
descriptors, the X or tty descriptor PLUS the subprocess output
descriptors. They no longer use permanent IO thread events to handle
the latter.
Edwin's remaining uses of permanently-register-io-thread-event are in
single-threaded OS2 and Win32 worlds. The runtime's only uses are in
the OS2 and X11 graphics devices where the IO *is* consumed during the
event.
Matt Birkholz [Thu, 26 Nov 2015 05:38:20 +0000 (22:38 -0700)]
doc/user-manual: Unix Installation: minor edits.
Fix gdbm plugin instructions; there is no configure script in src/gdbm/.
Matt Birkholz [Thu, 26 Nov 2015 05:37:00 +0000 (22:37 -0700)]
svm: finish-cross-compilation of everything using a large heap.
Matt Birkholz [Thu, 26 Nov 2015 05:33:35 +0000 (22:33 -0700)]
Update versions to 9.2.1.
Matt Birkholz [Thu, 26 Nov 2015 05:19:22 +0000 (22:19 -0700)]
Update copyright years.
$ mit-scheme --load dist/update-copyright \
_ --eval '(begin (translate-standard-dirs "./" translate-copyright) (%exit))'
Matt Birkholz [Thu, 26 Nov 2015 05:17:37 +0000 (22:17 -0700)]
dist/update-copyright.scm: Translate last-copyright-year.
Matt Birkholz [Thu, 26 Nov 2015 05:17:15 +0000 (22:17 -0700)]
dist/update-copyright.scm: Update files in place.
Rather than store the changed files in a dirtree rooted at
translated-files/. Start with a clean working tree and you can `git
reset --hard HEAD' when the translation goes badly.
Taylor R Campbell [Tue, 27 Oct 2015 13:51:59 +0000 (13:51 +0000)]
Document REFERENCE-BARRIER.
Matt Birkholz [Thu, 3 Sep 2015 20:17:46 +0000 (13:17 -0700)]
ffi: Fix callouts that return a struct or union.
I missed a hunk while porting Peter Feigl <craven@gmx.net>'s patch to
commit
cf1e855.
Matt Birkholz [Wed, 19 Aug 2015 01:00:50 +0000 (18:00 -0700)]
Use without-interruption and more locking(!) in gcfinal.scm.
Prepare the GC daemon to run concurrently with other threads; lock each
finalizer while it is cleaned in run-gc-finalizers.
Add without-interruption to add-to-, remove-from-, remove-all-from-,
with--lock, and make-gc-finalized-object, NOT to search- or -elements.
Reset-gc-finalizers also lost its without-interrupts, but it is an
after-restore event already executed without-interrupts.
Matt Birkholz [Tue, 23 Jun 2015 18:01:26 +0000 (11:01 -0700)]
Remove without-interrupts from runtime/process.scm.
Serial access to a subprocess is the responsibility of the user. Thus
subprocess-i/o-port and close-subprocess-i/o do not need without-
interrupts to implement it.
Closing a port twice should not signal an error, so subprocess-delete
and close-subprocess-i/o do not need even without-interruption.
However they should close the port before clearing the subprocess
slot, else an abort could drop the port and it's channels may not be
closed for an arbitrarily long time.
Status sync could miss changes and subprocess-i/o-port and
make-subprocess could drop a subprocess or port if aborted mid-stride.
They now use without-interruption.
Matt Birkholz [Fri, 10 Jul 2015 19:03:02 +0000 (12:03 -0700)]
Remove without-interrupts from runtime/os2graph.scm.
Matt Birkholz [Fri, 19 Jun 2015 20:22:48 +0000 (13:22 -0700)]
Remove without-interrupts from runtime/x11graph.scm.
Replaced it with without-interruption. Presumably the desire was to
keep the permanently registered IO thread event from interrupting
itself.
Matt Birkholz [Fri, 19 Jun 2015 17:51:15 +0000 (10:51 -0700)]
Remove without-interrupts from runtime/random.scm.
Use a mutex to serialize access to the default random state. Serial
access to other random states is still the responsibility of the user.
Matt Birkholz [Fri, 19 Jun 2015 20:04:04 +0000 (13:04 -0700)]
Remove without-interrupts from runtime/queue.scm.
Add make-serial-queue and use it in runtime globals: the event
distributors, GC daemons and REPLs. Note that the "safe" queue
operations, when applied to non-serializing queues in SMPing worlds,
are NOT thread-safe. This only happens in LIAR, SWAT, Edwin, X11
Graphics and OS2 Graphics -- single-threaded applications.
Matt Birkholz [Wed, 1 Jul 2015 14:34:59 +0000 (07:34 -0700)]
Serialize access to the population-of-1d-tables.
Allow create-thread to be run by multiple threads concurrently while
still accessing the population-of-1d-tables serially.
Matt Birkholz [Sun, 12 Jul 2015 23:47:14 +0000 (16:47 -0700)]
Remove without-interrupts from runtime/intrpt.scm.
It was only used in the internal install procedure where an "atomic"
updated was described. Punted that and assumed the procedure is not
run in multiple threads concurrently. It should be called only during
the single-threaded cold load or in a careful developer's REPL(?).
Matt Birkholz [Mon, 13 Jul 2015 22:57:03 +0000 (15:57 -0700)]
Remove without-interrupts from runtime/io.scm.
Channel-read and channel-write used without-interrupts for atomicity,
to avoid calling primitives with a channel another thread has closed.
The resulting errors may have been expensive to handle, but the cheap
technique of calling without-interrupts is ineffective in SMPing
worlds. Assuming most channels are used by one thread and will not
encounter these errors, just punt the calls to without-interrupts.
Serialize modifications to the channel table (esp. channel-close) via
the open-channels gc finalizer's atomic section and the new
with-gc-finalizer-lock procedure.
Remove tty-input-channel and tty-output-channel from general use.
They are only used in a cold load initialize-package! procedure and an
after-restore reset-console procedure. They are not fit for general
use, creating a new channel object each time they are called, only the
newest one of which is returned by descriptor->channel. Assume these
procedures are only used in single threaded fashion.
In open-pty-master, directory-channel-open and make-select-registry,
replace without-interrupts with without-interruption to avoid dropping
a channel or registry because of an inopportune abort. GC finalizers
like open-channels and open-directories (and select-registry-
finalizer) are already serializing.
Do NOT export channel-descriptor-for-select to the () package. Assume
select registries and their result vectors are used ONLY internally,
in single threaded fashion, by the thread system. Punt the
unnecessary and now useless calls to without-interrupts.
In dld-load-file and dld-unload-file, serialize access to the
dld-handles via dld-handles-mutex.
Matt Birkholz [Tue, 23 Jun 2015 23:01:51 +0000 (16:01 -0700)]
Remove without-interrupts from runtime/infutl.scm.
Without-interrupts was used to make atomic accesses to the
uncompressed-files cache and the wrappers-with-memoized-debugging-info
population. To replace it, a serial population is used and the
uncompressed-files cache is punted. The latter is hopefully
unnecessary on modern machinery.
Matt Birkholz [Thu, 18 Jun 2015 19:23:48 +0000 (12:23 -0700)]
Remove without-interrupts from runtime/hashtb.scm.
Serial access to particular hash tables is (now?) the responsibility
of the user -- all access, not just modifications (because of lazy
rehashing). Serial access to the list of all address hash tables is
now the responsiblity of a serial population.
Most calls to with-table-locked! (aka without-interrupts) are now
calls to without-interruption (to postpone inopportune aborts).
Matt Birkholz [Thu, 18 Jun 2015 19:56:42 +0000 (12:56 -0700)]
Remove with-absolutely-no-interrupts from runtime/hash.scm.
Use a thread mutex to serialize access. Simplify an ancient
implementation by using the new datum weak and key weak hash table
types. Initialize the package AFTER (runtime hash-table).
Matt Birkholz [Mon, 13 Jul 2015 00:23:52 +0000 (17:23 -0700)]
Remove without-interrupts from runtime/global.scm.
Clean-obarray runs as a secondary-gc-deamon and thus, in SMPing
worlds, it may run in parallel with other threads on other processors.
A number of primitives and compiler utilities modify the obarray so an
SMPing microcode will use a pthread mutex to serialize access to it.
Clean-obarray now uses a new procedure, with-obarray-lock, that uses
new primitives to participate in the serialization.
Matt Birkholz [Fri, 19 Jun 2015 17:31:37 +0000 (10:31 -0700)]
Remove without-interrupts from runtime/generic.scm.
Serial access to particular generic functions is still the
responsibility of the user. Serial access to the
generic-procedure-records table is now ensured by a thread mutex.
Matt Birkholz [Thu, 18 Jun 2015 18:24:43 +0000 (11:24 -0700)]
Remove without-interrupts from runtime/geneqht.scm.
Serial access to a particular table is still the responsibility of the
user (e.g. SOS procedures?), but the list of all address hash tables
is now a serial population.
Matt Birkholz [Thu, 18 Jun 2015 18:22:42 +0000 (11:22 -0700)]
Add make-serial-population.
Also add empty-population! and for-each-inhabitant.
Do not export the /unsafe procedures even to (runtime); require that
they be explicitly imported (specifically exported?). Use the /unsafe
procedures in (runtime 1d-property) and (runtime thread) package
initializations to avoid trying to lock the population-of-populations
too early in the cold load.
Matt Birkholz [Mon, 13 Jul 2015 22:54:49 +0000 (15:54 -0700)]
Remove without-interrupts from runtime/gcfinal.scm.
Serialize access to the list of gc finalizers and to each finalizer.
Matt Birkholz [Mon, 6 Jul 2015 00:58:03 +0000 (17:58 -0700)]
Initialize the thread system early in the cold load.
Thus with-thread-mutex-lock can be used during initialization of most
packages. Avoid using the global set-interrupt-enables! binding in
dynamic-wind because it is now called so early.
This anticipates removing without-interrupts from gcfinal.scm and thus
calling with-thread-mutex-lock during make-gc-finalizer, e.g. during
the initialization of the (runtime string) package.
Matt Birkholz [Tue, 23 Jun 2015 18:42:13 +0000 (11:42 -0700)]
Remove with-absolutely-no-interrupts from runtime/gc.scm.
Default/purify and default/gc-flip modified the constant-space-queue
under the cover of with-absolutely-no-interrupts, which is no longer
atomic. Serializing these procedures is a trick because the latter is
invoked by the GC interrupt. (Thus ABSOLUTELY no interrupts were
allowed?)
But there is no need for default/gc-flip to remove items from the
queue. Flush-purification-queue! will know that its queue is "empty"
when its head is in constant space. Thus the interrupt no longer
modifies the queue, and the queuing process is serialized in the usual
way.
Since primitive-purify cannot fail for lack of space, ancient error
signals and retry loops are also eliminated.
Matt Birkholz [Wed, 17 Jun 2015 03:03:56 +0000 (20:03 -0700)]
Define make-thread-mutex early.
Global data structures like event-distributors and gc-daemon queues
need to serialize operations and could use thread mutexes except that
they are naturally created early in the cold load, before the thread
system is loaded. So the mutex data structure is defined (withOUT
define-structure syntax) in a new file: runtime/thread-low.scm. The
rest of thread.scm must be loaded after record.scm.
This breaks the circularity where thread system initialization
requires population and 1d-table operations which are serialized by
the thread system.
Matt Birkholz [Wed, 17 Jun 2015 02:35:31 +0000 (19:35 -0700)]
Remove without-interrupts from runtime/sfile.scm.
Serialize access to the files-to-delete element of the fixed-objects
vector.
Matt Birkholz [Wed, 17 Jun 2015 02:34:03 +0000 (19:34 -0700)]
Remove without-interrupts from runtime/rgxcmp.scm.
Add a mutex to each of the memoization caches.
Matt Birkholz [Tue, 14 Jul 2015 01:35:18 +0000 (18:35 -0700)]
Remove without-interrupts from runtime/ffi.scm.
Modifications to the registered-callbacks vector and the malloced
aliens list are now serialized by mutexes. Call-alien now uses
without-preemption during a callout (and its callbacks).
Matt Birkholz [Fri, 10 Jul 2015 02:30:06 +0000 (19:30 -0700)]
Add without-preemption.
Matt Birkholz [Wed, 17 Jun 2015 02:21:46 +0000 (19:21 -0700)]
Remove without-interrupts from runtime/string.scm.
It was only used to postpone aborts that would drop an external string
descriptor. The interrupt mask manipulation in %string-head! only
postpones a GC flip while the local heap is edited.
Matt Birkholz [Wed, 17 Jun 2015 02:21:19 +0000 (19:21 -0700)]
Remove without-interrupts from runtime/rbtree.scm.
It was only used to postpone aborts that would leave data structures
inconsistent.
Matt Birkholz [Wed, 17 Jun 2015 02:20:31 +0000 (19:20 -0700)]
Unalias with-absolutely-no-interrupts in runtime/prgcop.scm.
It is not atomic in multiprocessing worlds. The alias "atomically" is
no longer appropriate.
Matt Birkholz [Wed, 17 Jun 2015 02:18:21 +0000 (19:18 -0700)]
Remove without-interrupts from runtime/parser-buffer.scm.
It was only used to postpone aborts that would leave data structures
inconsistent.
Matt Birkholz [Wed, 17 Jun 2015 02:16:21 +0000 (19:16 -0700)]
Remove without-interrupts from runtime/gencache.scm.
It was only used to postpone aborts that would leave data structures
inconsistent. Access to these caches needs to be serial.
Matt Birkholz [Wed, 17 Jun 2015 02:15:57 +0000 (19:15 -0700)]
Remove without-interrupts from runtime/gdbm.scm.
It was only used to postpone aborts that would leak gdbfs.
Matt Birkholz [Wed, 17 Jun 2015 02:15:05 +0000 (19:15 -0700)]
Remove without-interrupts from runtime/crypto.scm.
It was only used to postpone aborts that would leak mhash contexts.
Matt Birkholz [Wed, 17 Jun 2015 02:13:46 +0000 (19:13 -0700)]
Remove without-interrupts from runtime/condvar.scm.
Multi-threaded access to the chain of waiters is already adequately
serialized by the condition-variable.lock. Without-interrupts was
only intended to postpone aborts that would leave a doubly-linked
chain without a complete pair of links.
Matt Birkholz [Sun, 12 Jul 2015 22:18:25 +0000 (15:18 -0700)]
Add without-interruption, to replace without-interrupts.
Without-interruption will replace without-interrupts wherever
exclusivity is not thought to be needed -- just uninterruptibility.
Without-interrupts is deprecated because it is broken in multi-
processing worlds where it cannot provide exclusive access to the heap
as it does in uniprocessing worlds.
Matt Birkholz [Sun, 12 Jul 2015 22:10:53 +0000 (15:10 -0700)]
mhash: Prepare the GC daemon to run concurrently with other threads.
Matt Birkholz [Thu, 23 Jul 2015 16:21:01 +0000 (09:21 -0700)]
gdbm: Prepare the GC daemon to run concurrently with other threads.
Matt Birkholz [Sun, 12 Jul 2015 22:42:00 +0000 (15:42 -0700)]
Add with-thread-mutex-try-lock.
Matt Birkholz [Sat, 11 Jul 2015 00:26:23 +0000 (17:26 -0700)]
Look for IO in yield-current-thread.
Matt Birkholz [Sat, 11 Jul 2015 19:32:52 +0000 (12:32 -0700)]
Add type-checking to thread-dead?.
Matt Birkholz [Wed, 17 Jun 2015 01:56:30 +0000 (18:56 -0700)]
debug.c (print_string): Summarize long strings.
Matt Birkholz [Sat, 6 Jun 2015 00:51:33 +0000 (17:51 -0700)]
Mark with-thread-events-blocked stack frames with the symbol.
These frames can then be recognized in Debug_Stack_Trace output.
Matt Birkholz [Wed, 1 Jul 2015 15:03:48 +0000 (08:03 -0700)]
Punt unused variable slots and mention of dangerous bindings.