pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   #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;      #ifdef _REENTRANT   #include "threads.h"   #include "array.h"   #include "object.h"   #include "pike_macros.h"   #include "callback.h"
pike.git/src/threads.c:151:   #endif      struct thread_starter   {    struct object *id;    struct array *args;   };      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;       THREADS_ALLOW();       /* Keep this the entire session. */    mt_lock(&interleave_lock);       im = (IMUTEX_T *)interleave_list;
pike.git/src/threads.c:190:       im = (IMUTEX_T *)interleave_list;       while(im) {    mt_lock(&(im->lock));       im = im->next;    }    }    -  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_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 -  */ + 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();    }   } - } +       void exit_threads_disable(struct object *o)   {    THREADS_FPRINTF(0, (stderr, "exit_threads_disable(): threads_disabled:%d\n",    threads_disabled));    if(threads_disabled) {    if(!--threads_disabled) {    IMUTEX_T *im = (IMUTEX_T *)interleave_list;       /* Order shouldn't matter for unlock, so no need to do it backwards. */