From: Matt Birkholz Date: Tue, 21 Jul 2015 09:11:12 +0000 (-0700) Subject: Make trap_state and current_interruptable_extent thread-local. X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=5f557c2dbac44c4885aec03163db5cabfea57bbd;p=mit-scheme.git Make trap_state and current_interruptable_extent thread-local. Split the thread-local parts of UX_initialize_trap_recovery into UX_initialize_trap_state, and those of OS_initialize into OS_initialize_processor. Call the latter in OS_initialize and the co-processors' work function. --- diff --git a/src/microcode/intext.c b/src/microcode/intext.c index 95d9b809a..152efbc01 100644 --- a/src/microcode/intext.c +++ b/src/microcode/intext.c @@ -28,7 +28,7 @@ USA. extern void preserve_signal_mask (void); -struct interruptable_extent * current_interruptable_extent; +__thread struct interruptable_extent * current_interruptable_extent; void initialize_interruptable_extent (void) diff --git a/src/microcode/intext.h b/src/microcode/intext.h index efa675bf0..d2c5c6451 100644 --- a/src/microcode/intext.h +++ b/src/microcode/intext.h @@ -36,7 +36,7 @@ struct interruptable_extent int interrupted; }; -extern struct interruptable_extent * current_interruptable_extent; +extern __thread struct interruptable_extent * current_interruptable_extent; extern void initialize_interruptable_extent (void); extern void reset_interruptable_extent (void); extern struct interruptable_extent * enter_interruptable_extent (void); diff --git a/src/microcode/ostop.h b/src/microcode/ostop.h index 4cf99044c..aac3c73ab 100644 --- a/src/microcode/ostop.h +++ b/src/microcode/ostop.h @@ -31,6 +31,9 @@ USA. extern int OS_under_emacs_p (void); extern void OS_initialize (void); +#ifdef ENABLE_SMP +extern void OS_initialize_processor (void); +#endif extern void OS_reset (void); extern void OS_quit (int code, int abnormal_p); extern void OS_restartable_exit (void); diff --git a/src/microcode/prossmp.c b/src/microcode/prossmp.c index c0dc5cf10..c65a08cf4 100644 --- a/src/microcode/prossmp.c +++ b/src/microcode/prossmp.c @@ -31,6 +31,7 @@ USA. #ifdef ENABLE_SMP #include "history.h" +#include "ostop.h" #include "osio.h" #include @@ -205,6 +206,7 @@ work (void *p) assert (self != processors); initialize_processor_early (); reset_processor_allocator (self); + OS_initialize_processor (); RESET_HISTORY (); /* expr: (SMP-PAUSE) */ diff --git a/src/microcode/uxtop.c b/src/microcode/uxtop.c index 405835bb5..29014d485 100644 --- a/src/microcode/uxtop.c +++ b/src/microcode/uxtop.c @@ -48,6 +48,7 @@ extern void UX_initialize_environment (void); extern void UX_initialize_processes (void); extern void UX_initialize_signals (void); extern void UX_initialize_terminals (void); +extern void UX_initialize_trap_state (void); extern void UX_initialize_trap_recovery (void); extern void UX_initialize_tty (void); extern void UX_initialize_userio (void); @@ -71,9 +72,15 @@ OS_under_emacs_p (void) } void -OS_initialize (void) +OS_initialize_processor (void) { initialize_interruptable_extent (); + UX_initialize_trap_state (); +} + +void +OS_initialize (void) +{ { interactive = (option_force_interactive @@ -96,6 +103,7 @@ OS_initialize (void) UX_initialize_processes (); UX_initialize_trap_recovery (); UX_initialize_directory_reader (); + OS_initialize_processor (); OS_Name = SYSTEM_NAME; OS_Variant = SYSTEM_VARIANT; #if defined(_SUNOS) || defined(_SUNOS3) || defined(_SUNOS4) diff --git a/src/microcode/uxtrap.c b/src/microcode/uxtrap.c index aaf52b4d8..f6c7e5bd3 100644 --- a/src/microcode/uxtrap.c +++ b/src/microcode/uxtrap.c @@ -96,12 +96,12 @@ enum pc_location # define SPECIAL_SIGNAL_CODE_NAMES() #endif -static enum trap_state trap_state; -static enum trap_state user_trap_state; -static enum trap_state saved_trap_state; -static int saved_signo; -static SIGINFO_T saved_info; -static SIGCONTEXT_T * saved_scp; +static __thread enum trap_state trap_state; +static __thread enum trap_state user_trap_state; +static __thread enum trap_state saved_trap_state; +static __thread int saved_signo; +static __thread SIGINFO_T saved_info; +static __thread SIGCONTEXT_T * saved_scp; static void continue_from_trap (int, SIGINFO_T, SIGCONTEXT_T *); @@ -136,10 +136,15 @@ static void trap_dump_core (void); static void trap_recover (void); void -UX_initialize_trap_recovery (void) +UX_initialize_trap_state (void) { trap_state = trap_state_recover; user_trap_state = trap_state_recover; +} + +void +UX_initialize_trap_recovery (void) +{ initialize_ux_signal_codes (); } diff --git a/src/microcode/uxtrap.h b/src/microcode/uxtrap.h index 90c383b00..c33cff3d8 100644 --- a/src/microcode/uxtrap.h +++ b/src/microcode/uxtrap.h @@ -828,6 +828,7 @@ enum trap_state }; extern void UX_initialize_trap_recovery (void); +extern void UX_initialize_trap_state (void); extern enum trap_state OS_set_trap_state (enum trap_state state); extern void hard_reset (SIGCONTEXT_T * scp); extern void soft_reset (void);