From: Matt Birkholz Date: Tue, 21 Jul 2015 20:13:06 +0000 (-0700) Subject: Add SMP-WAKE primitive. X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=6ced0cd9c04e4307a7e851e0d70b042801e40333;p=mit-scheme.git Add SMP-WAKE primitive. --- 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