mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 15:40:19 +02:00
Use atomics for async interrupts
* libguile/__scm.h (SCM_TICK): Always define as scm_async_tick(). * libguile/error.c (scm_syserror, scm_syserror_msg): * libguile/fports.c (fport_read, fport_write): * libguile/_scm.h (SCM_SYSCALL): Replace SCM_ASYNC_TICK with scm_async_tick (). (SCM_ASYNC_TICK, SCM_ASYNC_TICK_WITH_CODE) (SCM_ASYNC_TICK_WITH_GUARD_CODE): Remove internal definitions. We inline into vm-engine.c, the only place where it matters. * libguile/async.h: * libguile/async.c (scm_async_tick, scm_i_setup_sleep): (scm_i_reset_sleep, scm_system_async_mark_for_thread): * libguile/threads.h (struct scm_thread_wake_data): * libguile/threads.h (scm_i_thread): * libguile/threads.c (block_self, guilify_self_1, scm_std_select): Rewrite to use sequentially-consistent atomic references. * libguile/atomics-internal.h (scm_atomic_set_pointer): (scm_atomic_ref_pointer): New definitions. * libguile/finalizers.c (queue_finalizer_async): We can allocate, so just use scm_system_async_mark_for_thread instead of the set-cdr! shenanigans. * libguile/scmsigs.c (take_signal): * libguile/gc.c (queue_after_gc_hook): Adapt to new asyncs mechanism. Can't allocate but we're just manipulating the current thread when no other threads are running so we should be good. * libguile/vm-engine.c (VM_HANDLE_INTERRUPTS): Inline the async_tick business.
This commit is contained in:
parent
f3bfe29235
commit
c957ec7ab0
14 changed files with 152 additions and 192 deletions
|
@ -127,10 +127,25 @@
|
|||
#define ABORT_CONTINUATION_HOOK() \
|
||||
RUN_HOOK0 (abort)
|
||||
|
||||
#define VM_HANDLE_INTERRUPTS \
|
||||
SCM_ASYNC_TICK_WITH_GUARD_CODE (thread, SYNC_IP (), CACHE_SP ())
|
||||
/* TODO: Invoke asyncs without trampolining out to C. That will let us
|
||||
preempt computations via an asynchronous interrupt. */
|
||||
#define VM_HANDLE_INTERRUPTS \
|
||||
do \
|
||||
if (SCM_LIKELY (thread->block_asyncs == 0)) \
|
||||
{ \
|
||||
SCM asyncs = scm_atomic_ref_scm (&thread->pending_asyncs); \
|
||||
if (SCM_UNLIKELY (!scm_is_null (asyncs))) \
|
||||
{ \
|
||||
SYNC_IP (); \
|
||||
scm_async_tick (); \
|
||||
CACHE_SP (); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
|
||||
|
||||
/* Virtual Machine
|
||||
|
||||
The VM has three state bits: the instruction pointer (IP), the frame
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue