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.194 2003/01/05 01:00:08 nilsson Exp $ + || $Id: threads.c,v 1.195 2003/01/08 19:32:08 mast Exp $   */      #include "global.h" - RCSID("$Id: threads.c,v 1.194 2003/01/05 01:00:08 nilsson Exp $"); + RCSID("$Id: threads.c,v 1.195 2003/01/08 19:32:08 mast Exp $");      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT 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:401:    }       /* Just to be nice... */    mt_unlock(&(im->lock));       exit_threads_disable(NULL);   }      /* Thread hashtable */    - #define THREAD_TABLE_SIZE 127 /* Totally arbitrary prime */ + struct thread_state *thread_table_chains[THREAD_TABLE_SIZE]; + int num_pike_threads=0;    - 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)   {    return th_hash(*tid) % THREAD_TABLE_SIZE;
pike.git/src/threads.c:568:    *! This function returns an array with the thread ids of all threads.    *!    *! @seealso    *! @[Thread()]    */   PMOD_EXPORT void f_all_threads(INT32 args)   {    /* Return an unordered array containing all threads that was running    at the time this function was invoked */    -  INT32 x; +     struct svalue *oldsp;    struct thread_state *s;       pop_n_elems(args);    oldsp = Pike_sp; -  mt_lock( & thread_table_lock ); -  for(x=0; x<THREAD_TABLE_SIZE; x++) -  for(s=thread_table_chains[x]; s; s=s->hashlink) { +  FOR_EACH_THREAD (s, {    struct object *o = THREADSTATE2OBJ(s);    if (o) {    ref_push_object(o);    } -  } -  mt_unlock( & thread_table_lock ); +  });    f_aggregate(DO_NOT_WARN(Pike_sp - oldsp));   }      #ifdef PIKE_DEBUG   void debug_list_all_threads(void)   {    INT32 x;    struct thread_state *s;    THREAD_T self = th_self();   
pike.git/src/threads.c:720: Inside #if defined(PIKE_DEBUG)
   Pike_fatal("Current thread is wrong. %lx %lx\n",    (long)OBJ2THREAD(Pike_interpreter.thread_id)->id, (long)self);       if(thread_for_id(th_self()) != Pike_interpreter.thread_id) {    debug_list_all_threads();    Pike_fatal("thread_for_id() (or Pike_interpreter.thread_id) failed! %p != %p\n",thread_for_id(th_self()),Pike_interpreter.thread_id) ;    }    }   #endif    - #ifdef THREAD_TRACE -  { +     t_flag = default_t_flag; -  } - #endif /* THREAD_TRACE */ +        THREADS_FPRINTF(0, (stderr,"THREAD %08x INITED\n",(unsigned int)Pike_interpreter.thread_id));       DO_IF_DEBUG(    if(thread_for_id(th_self()) != Pike_interpreter.thread_id) {    debug_list_all_threads();    Pike_fatal("thread_for_id() (or Pike_interpreter.thread_id) failed! %p != %p\n",thread_for_id(th_self()),Pike_interpreter.thread_id) ;    } )      
pike.git/src/threads.c:1621: Inside #if defined(PIKE_DEBUG)
   /* Only used by with locate_references. */    if (Pike_in_gc == GC_PASS_LOCATE) {    struct svalue key, *val;    INT32 x;    struct thread_state *s;       key.u.integer = ((struct thread_local *)CURRENT_STORAGE)->id;    key.type = T_INT;    key.subtype = NUMBER_NUMBER;    -  /* Hmm, should this be used here? We know we always got the -  * interpreter lock. */ -  /* mt_lock( & thread_table_lock ); */ -  for(x=0; x<THREAD_TABLE_SIZE; x++) -  for(s=thread_table_chains[x]; s; s=s->hashlink) { +  FOR_EACH_THREAD (s, {    if (s->thread_local &&    (val = low_mapping_lookup(s->thread_local, &key)))    debug_gc_check_svalues2(val, 1, T_OBJECT, o,    " as thread local value in Thread.Local object"    " (indirect ref)"); -  +  });    } -  /* mt_unlock( & thread_table_lock ); */ +    } - } +    #endif      /*! @endclass    */      /*! @endmodule    */      /* Thread farm code by Per    *