pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: threads.c,v 1.276 2009/03/13 21:03:47 mast Exp $ + || $Id: threads.c,v 1.277 2009/03/13 21:06:54 mast Exp $   */      #include "global.h"      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0;      /* #define PICKY_MUTEX */      #ifdef _REENTRANT
pike.git/src/threads.c:43:   #include <errno.h>      #ifdef HAVE_SYS_PRCTL_H   #include <sys/prctl.h>   #endif /* HAVE_SYS_PRCTL_H */      #ifdef HAVE_SYS_TIME_H   #include <sys/time.h>   #endif    - PMOD_EXPORT int live_threads = 0, disallow_live_threads = 0; + PMOD_EXPORT int live_threads = 0;   PMOD_EXPORT COND_T live_threads_change;   PMOD_EXPORT COND_T threads_disabled_change;      #else   #include "pike_threadlib.h"   #endif /* !CONFIGURE_TEST */      #ifndef PIKE_THREAD_C_STACK_SIZE   #define PIKE_THREAD_C_STACK_SIZE (256 * 1024)   #endif
pike.git/src/threads.c:462:    *! You should make sure that the returned object is freed even if    *! some kind of error is thrown. That means in practice that it    *! should only have references (direct or indirect) from function    *! local variables. Also, it shouldn't be referenced from cyclic    *! memory structures, since those are only destructed by the periodic    *! gc. (This advice applies to mutex locks in general, for that    *! matter.)    */   void init_threads_disable(struct object *o)   { -  disallow_live_threads = 1; +  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));    low_co_wait_interpreter(&live_threads_change);    }    SWAP_IN_CURRENT_THREAD();    } -  -  low_init_threads_disable(); +    }      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;   
pike.git/src/threads.c:499:    THREADS_FPRINTF(0,    (stderr,    "exit_threads_disable(): Unlocking IM 0x%p\n", im));    mt_unlock(&(im->lock));    im = im->next;    }       mt_unlock(&interleave_lock);       THREADS_FPRINTF(0, (stderr, "_exit_threads_disable(): Wake up!\n")); -  disallow_live_threads = 0; +     co_broadcast(&threads_disabled_change);   #ifdef PIKE_DEBUG    threads_disabled_thread = 0;   #endif    }   #ifdef PIKE_DEBUG    } else {    Pike_fatal("exit_threads_disable() called too many times!\n");   #endif /* PIKE_DEBUG */    }