pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   #include "global.h" - RCSID("$Id: threads.c,v 1.26 1997/09/01 00:59:33 per Exp $"); + RCSID("$Id: threads.c,v 1.27 1997/09/01 14:14:30 per Exp $");      int num_threads = 1;   int threads_disabled = 0;      #ifdef _REENTRANT   #include "threads.h"   #include "array.h"   #include "object.h"   #include "pike_macros.h"   #include "callback.h"
pike.git/src/threads.c:174:      #define OB2KEY(X) ((struct key_storage *)((X)->storage))      void f_mutex_lock(INT32 args)   {    struct mutex_storage *m;    struct object *o;       pop_n_elems(args);    m=THIS_MUTEX; -  +  o=clone_object(mutex_key,0); +  mt_lock(& mutex_kluge);    if(m->key && OB2KEY(m->key)->owner == thread_id)    { -  push_int(0); +  m->key->refs++; +  push_object(m->key); +  mt_unlock(&mutex_kluge);    return; -  +  +  mt_unlock(&mutex_kluge);    error("Recursive mutex locks!\n");    }    -  o=clone_object(mutex_key,0); -  mt_lock(& mutex_kluge); +     THREADS_ALLOW();    while(m->key) co_wait(& m->condition, & mutex_kluge);    OB2KEY(o)->mut=m;    OB2KEY(o)->owner=thread_id;    m->key=o;       mt_unlock(&mutex_kluge);    THREADS_DISALLOW();    push_object(o);   }
pike.git/src/threads.c:205:   void f_mutex_trylock(INT32 args)   {    struct mutex_storage *m;    struct object *o;    int i=0;    pop_n_elems(args);       o=clone_object(mutex_key,0);    m=THIS_MUTEX;    +  mt_lock(& mutex_kluge); +     if(m->key && OB2KEY(m->key)->owner == thread_id) -  +  { +  mt_unlock(&mutex_kluge);    error("Recursive mutex locks!\n"); -  -  mt_lock(& mutex_kluge); +  }    THREADS_ALLOW();    if(!m->key)    {    OB2KEY(o)->mut=m;    OB2KEY(o)->owner=thread_id;    m->key=o;    i=1;    }    mt_unlock(&mutex_kluge);    THREADS_DISALLOW();
pike.git/src/threads.c:313:    {    /* Lock mutex */    while(mut->key) co_wait(& mut->condition, & mutex_kluge);    mut->key=key;    OB2KEY(key)->mut=mut;    }    mt_unlock(&mutex_kluge);    THREADS_DISALLOW();    pop_stack();    } else { +  mt_lock(&mutex_kluge);    THREADS_ALLOW(); -  co_wait(c, 0); +  co_wait(c, &mutex_kluge); +  mt_unlock(&mutex_kluge);    THREADS_DISALLOW();    }   }      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); }      void th_init(void)