From: Matt Birkholz Date: Tue, 21 Jul 2015 08:14:58 +0000 (-0700) Subject: Add SMP-IDLE primitive. X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=319664d98f5a65d40c66f94abd04be0cc2f72c62;p=mit-scheme.git Add SMP-IDLE primitive. --- diff --git a/src/microcode/prossmp.c b/src/microcode/prossmp.c index 8d02e58b4..17fb1702c 100644 --- a/src/microcode/prossmp.c +++ b/src/microcode/prossmp.c @@ -31,6 +31,7 @@ USA. #ifdef ENABLE_SMP #include "history.h" +#include "osio.h" #include /* The chain of processors, starting with processor0 -- main()'s thread: */ @@ -359,6 +360,38 @@ access to the thread system.") #endif } +DEFINE_PRIMITIVE ("SMP-IDLE", Prim_smp_idle, 0, 0, "(SMP-IDLE)\n\ +Wait for interrupts.") +{ + PRIMITIVE_HEADER (0); + +#ifdef ENABLE_SMP + assert (self->state == PROCESSOR_RUNNING || self->state == PROCESSOR_IDLE); + + trace (";%d SMP-Idle.", self->id); + self->state = PROCESSOR_IDLE; + + /* Abandon continuation. */ + stack_pointer = STACK_BOTTOM; + Will_Push (CONTINUATION_SIZE); + SET_RC (RC_END_OF_COMPUTATION); + SET_EXP (SHARP_F); + SAVE_CONT (); + Pushed (); + + SET_INTERRUPT_MASK (INT_Mask); + while (! (PENDING_INTERRUPTS_P)) + { + OS_pause (1); + trace (";%d SMP-Idle awoke to 0x%04x.", self->id, GET_INT_CODE); + } + self->state = PROCESSOR_RUNNING; + signal_interrupt_from_primitive (); +#else + signal_error_from_primitive (ERR_UNIMPLEMENTED_PRIMITIVE); +#endif +} + DEFINE_PRIMITIVE ("SMP-WAKE", Prim_smp_wake, 1, 1, "(SMP-WAKE id)\n\ Send a timer interrupt to processor ID.") {