diff --git a/src/threads.c b/src/threads.c index ffc6c5d7287e51718093726bd6cab60293cda37a..3e41bee78c8aa3a069831426bb9a7404d51acc9d 100644 --- a/src/threads.c +++ b/src/threads.c @@ -1,5 +1,5 @@ #include "global.h" -RCSID("$Id: threads.c,v 1.77 1998/07/17 12:57:15 grubba Exp $"); +RCSID("$Id: threads.c,v 1.78 1998/07/17 13:28:25 grubba Exp $"); int num_threads = 1; int threads_disabled = 0; @@ -158,12 +158,13 @@ struct thread_starter static volatile IMUTEX_T *interleave_list = NULL; -void init_threads_disable(struct object *o) +void low_init_threads_disable(void) { /* Serious black magic to avoid dead-locks */ if (!threads_disabled) { - THREADS_FPRINTF(0, (stderr, "init_threads_disable(): Locking IM's...\n")); + THREADS_FPRINTF(0, + (stderr, "low_init_threads_disable(): Locking IM's...\n")); if (thread_id) { IMUTEX_T *im; @@ -197,36 +198,33 @@ void init_threads_disable(struct object *o) } } - THREADS_FPRINTF(0, - (stderr, "init_threads_disable(): Disabling threads.\n")); + THREADS_FPRINTF(0, (stderr, + "low_init_threads_disable(): Disabling threads.\n")); threads_disabled = 1; } else { threads_disabled++; } - THREADS_FPRINTF(0, (stderr, "init_threads_disable(): threads_disabled:%d\n", - threads_disabled)); + THREADS_FPRINTF(0, + (stderr, "low_init_threads_disable(): threads_disabled:%d\n", + threads_disabled)); +} - if (o) { - /* The compiler desn't want to change thread, but doesn't mind - * other threads running in system calls etc. - * - * So we only wait here if we are called with non-NULL. - * - * /grubba 1998-07-17 - */ - if(live_threads) { - SWAP_OUT_CURRENT_THREAD(); - while (live_threads) { - THREADS_FPRINTF(0, - (stderr, - "_disable_threads(): Waiting for %d threads to finish\n", - live_threads)); - co_wait(&live_threads_change, &interpreter_lock); - } - SWAP_IN_CURRENT_THREAD(); +void init_threads_disable(struct object *o) +{ + low_init_threads_disable(); + + if(live_threads) { + SWAP_OUT_CURRENT_THREAD(); + while (live_threads) { + THREADS_FPRINTF(0, + (stderr, + "_disable_threads(): Waiting for %d threads to finish\n", + live_threads)); + co_wait(&live_threads_change, &interpreter_lock); } + SWAP_IN_CURRENT_THREAD(); } } diff --git a/src/threads.h b/src/threads.h index d5ed226e3fb1a6c7eee5386f8ba9dac53de65f46..52bfdcb4f2c97a59c81547e41baa7eb33be36f93 100644 --- a/src/threads.h +++ b/src/threads.h @@ -1,5 +1,5 @@ /* - * $Id: threads.h,v 1.45 1998/07/10 15:52:08 grubba Exp $ + * $Id: threads.h,v 1.46 1998/07/17 13:29:16 grubba Exp $ */ #ifndef THREADS_H #define THREADS_H @@ -477,6 +477,7 @@ struct thread_state *thread_state_for_id(THREAD_T tid); struct object *thread_for_id(THREAD_T tid); void f_all_threads(INT32 args); +void low_init_threads_disable(void); void init_threads_disable(struct object *o); void exit_threads_disable(struct object *o); @@ -510,6 +511,7 @@ void exit_interleave_mutex(IMUTEX_T *im); #define co_signal(X) #define co_broadcast(X) +#define low_init_threads_disable() #define init_threads_disable(X) #define exit_threads_disable(X)