pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   #include "global.h" - RCSID("$Id: threads.c,v 1.119 2000/11/06 17:05:00 grubba Exp $"); + RCSID("$Id: threads.c,v 1.120 2001/10/22 23:54:43 mast 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:548:         }      TH_RETURN_TYPE new_thread_func(void * data)   {    struct thread_starter arg = *(struct thread_starter *)data;    JMP_BUF back;    INT32 tmp;    -  THREADS_FPRINTF(0, (stderr,"THREADS_DISALLOW() Thread %08x created...\n", +  THREADS_FPRINTF(0, (stderr,"new_thread_func(): Thread %08x created...\n",    (unsigned int)arg.id));       if((tmp=mt_lock( & interpreter_lock)))    fatal("Failed to lock interpreter, return value=%d, errno=%d\n",tmp,   #ifdef __NT__    GetLastError()   #else    errno   #endif    ); -  +  +  while (threads_disabled) { +  THREADS_FPRINTF(1, (stderr, +  "new_thread_func(): Threads disabled\n")); +  co_wait(&threads_disabled_change, &interpreter_lock); +  } +     init_interpreter();    thread_id=arg.id;    stack_top=((char *)&data)+ (thread_stack_size-16384) * STACK_DIRECTION;    recoveries = NULL;    SWAP_OUT_THREAD(OBJ2THREAD(thread_id)); /* Init struct */    OBJ2THREAD(thread_id)->swapped=0;      #if defined(PIKE_DEBUG)    if(d_flag)    {
pike.git/src/threads.c:797:    if(threads_disabled)    {    free_object(o);    error("Cannot wait for mutexes when threads are disabled!\n");    }    SWAP_OUT_CURRENT_THREAD();    do    {    THREADS_FPRINTF(1, (stderr,"WAITING TO LOCK m:%08x\n",(unsigned int)m));    co_wait(& m->condition, & interpreter_lock); +  while (threads_disabled) { +  THREADS_FPRINTF(1, (stderr, +  "f_mutex_lock(): Threads disabled\n")); +  co_wait(&threads_disabled_change, &interpreter_lock); +  }    }while(m->key);    SWAP_IN_CURRENT_THREAD();    }    m->key=o;    OB2KEY(o)->mut=m;       DO_IF_DEBUG( if(thread_for_id(th_self()) != thread_id)    fatal("thread_for_id() (or thread_id) failed! %p != %p\n",thread_for_id(th_self()),thread_id) ; )       THREADS_FPRINTF(1, (stderr, "LOCK k:%08x, m:%08x(%08x), t:%08x\n",
pike.git/src/threads.c:965:    /* Unlock mutex */    mut->key=0;    OB2KEY(key)->mut=0;    co_signal(& mut->condition);       /* Wait and allow mutex operations */    SWAP_OUT_CURRENT_THREAD();    co_wait(c, &interpreter_lock);       /* Lock mutex */ -  while(mut->key) +  while(mut->key) {    co_wait(& mut->condition, &interpreter_lock); -  +  while (threads_disabled) { +  THREADS_FPRINTF(1, (stderr, +  "f_cond_wait(): Threads disabled\n")); +  co_wait(&threads_disabled_change, &interpreter_lock); +  } +  }    mut->key=key;    OB2KEY(key)->mut=mut;       SWAP_IN_CURRENT_THREAD();    pop_n_elems(args);    return;    }    }       SWAP_OUT_CURRENT_THREAD();    co_wait(c, &interpreter_lock); -  +  while (threads_disabled) { +  THREADS_FPRINTF(1, (stderr, +  "f_cond_wait(): Threads disabled\n")); +  co_wait(&threads_disabled_change, &interpreter_lock); +  }    SWAP_IN_CURRENT_THREAD();       pop_n_elems(args);   }      void f_cond_signal(INT32 args) { pop_n_elems(args); co_signal(THIS_COND); }   void f_cond_broadcast(INT32 args) { pop_n_elems(args); co_broadcast(THIS_COND); }   void init_cond_obj(struct object *o) { co_init(THIS_COND); }   void exit_cond_obj(struct object *o) { co_destroy(THIS_COND); }   
pike.git/src/threads.c:1032:    push_constant_text (")");    f_add (3);   }      static void f_thread_id_result(INT32 args)   {    struct thread_state *th=THIS_THREAD;       SWAP_OUT_CURRENT_THREAD();    -  while(th->status != THREAD_EXITED) +  while(th->status != THREAD_EXITED) {    co_wait(&th->status_change, &interpreter_lock); -  +  while (threads_disabled) { +  THREADS_FPRINTF(1, (stderr, +  "f_thread_id_result(): Threads disabled\n")); +  co_wait(&threads_disabled_change, &interpreter_lock); +  } +  }       SWAP_IN_CURRENT_THREAD();       low_object_index_no_free(sp,    fp->current_object,    thread_id_result_variable);    sp++;   }      void init_thread_obj(struct object *o)
pike.git/src/threads.c:1227:    new_farmer( fun, here );   }      void low_th_init(void)   {   #ifdef SGI_SPROC_THREADS   #error /* Need to specify a filename */    us_cookie = usinit("");   #endif /* SGI_SPROC_THREADS */    -  THREADS_FPRINTF(0, (stderr, "THREADS_DISALLOW() Initializing threads.\n")); +  THREADS_FPRINTF(0, (stderr, "low_th_init() Initializing threads.\n"));      #ifdef POSIX_THREADS   #ifdef HAVE_PTHREAD_INIT    pthread_init();   #endif /* HAVE_PTHREAD_INIT */   #endif /* POSIX_THREADS */       mt_init( & interpreter_lock);    mt_lock( & interpreter_lock);    mt_init( & thread_table_lock);