From 425b1522d5df54aaf80eaf47a007cf9600b405d5 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Sat, 20 Dec 2014 09:05:57 -0700 Subject: [PATCH] smp: Add smp-wake primitive. --- src/microcode/ossmp.h | 1 + src/microcode/prossmp.c | 24 ++++++++++++++++++++++++ src/microcode/uxsig.c | 6 ++++++ 3 files changed, 31 insertions(+) diff --git a/src/microcode/ossmp.h b/src/microcode/ossmp.h index 46a9c1be5..a51d0004d 100644 --- a/src/microcode/ossmp.h +++ b/src/microcode/ossmp.h @@ -71,6 +71,7 @@ extern bool smp_gc_started (void); extern void smp_gc_finished (void); extern void smp_kill_gc (pthread_t); +extern void smp_kill_timer (pthread_t); #endif diff --git a/src/microcode/prossmp.c b/src/microcode/prossmp.c index fe5ee1ee0..eab9c4797 100644 --- a/src/microcode/prossmp.c +++ b/src/microcode/prossmp.c @@ -529,6 +529,30 @@ Wait for interrupts.") #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); + processor_t *p; + for (p = processors; p != NULL; p = p->next) + if (p->id == id) + { + smp_kill_timer (p->pthread); + 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); +} + #ifdef ENABLE_SMP static SCHEME_OBJECT smp_idle_prim = SHARP_F; diff --git a/src/microcode/uxsig.c b/src/microcode/uxsig.c index 5b6347c9d..0d839f953 100644 --- a/src/microcode/uxsig.c +++ b/src/microcode/uxsig.c @@ -520,6 +520,12 @@ smp_kill_gc (pthread_t thread) pthread_kill (thread, SIGUSR2); } +void +smp_kill_timer (pthread_t thread) +{ + pthread_kill (thread, SIGALRM); +} + #endif /* ENABLE_SMP */ /* The following conditionalization would more naturally be expressed -- 2.25.1