pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   #include "global.h" - RCSID("$Id: threads.c,v 1.115 2000/03/25 20:58:30 hubbe Exp $"); + RCSID("$Id: threads.c,v 1.116 2000/03/30 04:39:17 hubbe Exp $");      int num_threads = 1;   int threads_disabled = 0;      #ifdef _REENTRANT   #include "threads.h"   #include "array.h"   #include "mapping.h"   #include "object.h"   #include "pike_macros.h"
pike.git/src/threads.c:371:    mt_unlock(&(im->lock));       exit_threads_disable(NULL);   }      /* Thread hashtable */      #define THREAD_TABLE_SIZE 127 /* Totally arbitrary prime */      static struct thread_state *thread_table_chains[THREAD_TABLE_SIZE]; + static int num_pike_threads=0;      void thread_table_init(void)   {    INT32 x;    for(x=0; x<THREAD_TABLE_SIZE; x++)    thread_table_chains[x] = NULL;   }      unsigned INT32 thread_table_hash(THREAD_T *tid)   {
pike.git/src/threads.c:414: Inside #if defined(PIKE_DEBUG)
   if(thread_state_for_id(s->id))    {    if(thread_state_for_id(s->id) == s)    fatal("Registring thread twice!\n");    else    fatal("Forgot to unregister thread!\n");    }   /* dumpmem("thread_table_insert",&s->id, sizeof(THREAD_T)); */   #endif    mt_lock( & thread_table_lock ); +  num_pike_threads++;    if((s->hashlink = thread_table_chains[h]) != NULL)    s->hashlink->backlink = &s->hashlink;    thread_table_chains[h] = s;    s->backlink = &thread_table_chains[h];    mt_unlock( & thread_table_lock );   }      void thread_table_delete(struct object *o)   {    struct thread_state *s = OBJ2THREAD(o);   /* dumpmem("thread_table_delete",&s->id, sizeof(THREAD_T)); */    mt_lock( & thread_table_lock ); -  +  num_pike_threads--;    if(s->hashlink != NULL)    s->hashlink->backlink = s->backlink;    *(s->backlink) = s->hashlink;    mt_unlock( & thread_table_lock );   }      struct thread_state *thread_state_for_id(THREAD_T tid)   {    unsigned INT32 h = thread_table_hash(&tid);    struct thread_state *s = NULL;
pike.git/src/threads.c:512:    mt_lock( & thread_table_lock );    for(x=0; x<THREAD_TABLE_SIZE; x++)    for(s=thread_table_chains[x]; s; s=s->hashlink) {    struct object *o = THREADSTATE2OBJ(s);    ref_push_object(o);    }    mt_unlock( & thread_table_lock );    f_aggregate(sp-oldsp);   }    + int count_pike_threads(void) + { +  return num_pike_threads; + }      static void check_threads(struct callback *cb, void *arg, void * arg2)   {    static int div_;    if(div_++ & 255) return;      #ifdef DEBUG    if(thread_for_id(th_self()) != thread_id)    fatal("thread_for_id() (or thread_id) failed!\n")   #endif