From 6ced0cd9c04e4307a7e851e0d70b042801e40333 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Tue, 21 Jul 2015 13:13:06 -0700 Subject: [PATCH] Add SMP-WAKE primitive. --- src/microcode/ossmp.h | 1 + src/microcode/prossmp.c | 23 +++++++++++++++++++++++ src/microcode/uxsig.c | 6 ++++++ 3 files changed, 30 insertions(+) diff --git a/src/microcode/ossmp.h b/src/microcode/ossmp.h index d5fc39bfb..61570364c 100644 --- a/src/microcode/ossmp.h +++ b/src/microcode/ossmp.h @@ -65,6 +65,7 @@ extern void smp_gc_start (void); extern void smp_gc_finish (void); extern void smp_kill_gc (processor_t *); +extern void smp_kill_timer (processor_t *); #ifdef ENABLE_DEBUGGING_TOOLS diff --git a/src/microcode/prossmp.c b/src/microcode/prossmp.c index fabbaa4cd..8d02e58b4 100644 --- a/src/microcode/prossmp.c +++ b/src/microcode/prossmp.c @@ -359,6 +359,29 @@ access to the thread system.") #endif } +DEFINE_PRIMITIVE ("SMP-WAKE", Prim_smp_wake, 1, 1, "(SMP-WAKE id)\n\ +Send a timer interrupt to processor ID.") +{ + PRIMITIVE_HEADER (0); + +#ifdef ENABLE_SMP + { + int id = arg_integer (1); + trace (";%d SMP-Wake %d.", self->id, id); + for (processor_t *p = processors; p != NULL; p = p->next) + if (p->id == id) + { + smp_kill_timer (p); + PRIMITIVE_RETURN (UNSPECIFIC); + } + outf_error_line (";%d smp-wake: bogus processor id %d", self->id, id); + } +#else + signal_error_from_primitive (ERR_UNIMPLEMENTED_PRIMITIVE); +#endif + PRIMITIVE_RETURN (UNSPECIFIC); +} + DEFINE_PRIMITIVE ("SMP-GC-WAIT", Prim_smp_gc_wait, 0, 0, "(SMP-GC-WAIT)\n\ Put the current processor in the GC-WAIT state.\n\ Called by the global-gc interrupt handler.") diff --git a/src/microcode/uxsig.c b/src/microcode/uxsig.c index 2f675f4c5..e00712e9b 100644 --- a/src/microcode/uxsig.c +++ b/src/microcode/uxsig.c @@ -519,6 +519,12 @@ smp_kill_gc (processor_t *p) pthread_kill (p->pthread, SIGUSR2); } +void +smp_kill_timer (processor_t *p) +{ + pthread_kill (p->pthread, SIGALRM); +} + #endif /* ENABLE_SMP */ /* The following conditionalization would more naturally be expressed -- 2.25.1