pike.git / src / threads.h

version» Context lines:

pike.git/src/threads.h:38:   #endif /* _MIT_POSIX_THREADS */      #ifdef _SGI_SPROC_THREADS   /* Not supported yet */   #undef SGI_SPROC_THREADS   #undef HAVE_SPROC   #endif /* _SGI_SPROC_THREADS */         extern int num_threads; + extern int live_threads;   struct object;   extern struct object *thread_id;      #define DEFINE_MUTEX(X) MUTEX_T X         #ifdef POSIX_THREADS   #define THREAD_T pthread_t   #define MUTEX_T pthread_mutex_t   #define mt_init(X) pthread_mutex_init((X),0)
pike.git/src/threads.h:214:   int co_wait(COND_T *c, MUTEX_T *m);   int co_signal(COND_T *c);   int co_broadcast(COND_T *c);   int co_destroy(COND_T *c);      #endif         extern MUTEX_T interpreter_lock;    + extern COND_T live_threads_change; /* Used by _disable_threads */ + extern COND_T threads_disabled_change; /* Used by _disable_threads */      struct svalue;   struct frame;      #define THREAD_NOT_STARTED -1   #define THREAD_RUNNING 0   #define THREAD_EXITED 1      struct thread_state {    char swapped;
pike.git/src/threads.h:331:   #else /* DEBUG */   #define HIDE_GLOBAL_VARIABLES()   #define REVEAL_GLOBAL_VARIABLES()   #endif /* DEBUG */         #define THREADS_ALLOW() do { \    struct thread_state *_tmp=(struct thread_state *)thread_id->storage; \    if(num_threads > 1 && !threads_disabled) { \    SWAP_OUT_THREAD(_tmp); \ -  THREADS_FPRINTF((stderr, "THREADS_ALLOW() %s:%d t:%08x\n", \ -  __FILE__, __LINE__, (unsigned int)_tmp->thread_id)); \ +  THREADS_FPRINTF((stderr, "THREADS_ALLOW() %s:%d t:%08x (#%d)\n", \ +  __FILE__, __LINE__, \ +  (unsigned int)_tmp->thread_id, live_threads)); \    mt_unlock(& interpreter_lock); \    } else {} \    HIDE_GLOBAL_VARIABLES()      #define THREADS_DISALLOW() \    REVEAL_GLOBAL_VARIABLES(); \    if(_tmp->swapped) { \    mt_lock(& interpreter_lock); \ -  THREADS_FPRINTF((stderr, "THREADS_DISALLOW() %s:%d ... t:%08x\n", \ -  __FILE__, __LINE__, (unsigned int)_tmp->thread_id)); \ +  THREADS_FPRINTF((stderr, "THREADS_DISALLOW() %s:%d... t:%08x (#%d)\n", \ +  __FILE__, __LINE__, \ +  (unsigned int)_tmp->thread_id, live_threads)); \ +  while (threads_disabled) { \ +  THREADS_FPRINTF((stderr, "THREADS_DISALLOW(): Threads disabled\n")); \ +  co_wait(&live_threads_change, &interpreter_lock); \ +  } \    SWAP_IN_THREAD(_tmp);\    } \    } while(0)    -  + #define THREADS_ALLOW_UID() do { \ +  struct thread_state *_tmp_uid=(struct thread_state *)thread_id->storage; \ +  if(num_threads > 1 && !threads_disabled) { \ +  SWAP_OUT_THREAD(_tmp_uid); \ +  live_threads++; \ +  THREADS_FPRINTF((stderr, "THREADS_ALLOW() %s:%d t:%08x (#%d)\n", \ +  __FILE__, __LINE__, \ +  (unsigned int)_tmp_uid->thread_id, live_threads)); \ +  mt_unlock(& interpreter_lock); \ +  } else {} \ +  HIDE_GLOBAL_VARIABLES() +  + #define THREADS_DISALLOW_UID() \ +  REVEAL_GLOBAL_VARIABLES(); \ +  if(_tmp_uid->swapped) { \ +  mt_lock(& interpreter_lock); \ +  live_threads--; \ +  THREADS_FPRINTF((stderr, "THREADS_DISALLOW() %s:%d... t:%08x (#%d)\n", \ +  __FILE__, __LINE__, \ +  (unsigned int)_tmp_uid->thread_id, live_threads)); \ +  while (threads_disabled) { \ +  THREADS_FPRINTF((stderr, "THREADS_DISALLOW(): Threads disabled\n")); \ +  co_signal(&live_threads_change); \ +  co_wait(&threads_disabled_change, &interpreter_lock); \ +  } \ +  SWAP_IN_THREAD(_tmp_uid);\ +  } \ +  } while(0) +    /* Prototypes begin here */   struct thread_starter;   void *new_thread_func(void * data);   void f_thread_create(INT32 args);   void f_thread_set_concurrency(INT32 args);   void f_this_thread(INT32 args);   struct mutex_storage;   struct key_storage;   void f_mutex_lock(INT32 args);   void f_mutex_trylock(INT32 args);