pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   #include "global.h" - RCSID("$Id: threads.c,v 1.112 2000/03/17 05:12:30 hubbe Exp $"); + RCSID("$Id: threads.c,v 1.113 2000/03/24 01:24:52 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:187: Inside #if defined(SIMULATE_COND_WITH_EVENT)
   t=c->head;    mt_unlock(& c->lock);    if(t) return -1;    mt_destroy(& c->lock);    return 0;   }      #endif       - #define THIS_THREAD ((struct thread_state *)fp->current_storage) + #define THIS_THREAD ((struct thread_state *)CURRENT_STORAGE)      struct object *thread_id = NULL;   static struct callback *threads_evaluator_callback=0;   int thread_id_result_variable;      MUTEX_T interpreter_lock, thread_table_lock, interleave_lock;   struct program *mutex_key = 0;   struct program *thread_id_prog = 0;   struct program *thread_local_prog = 0;   #ifdef POSIX_THREADS
pike.git/src/threads.c:625:       OBJ2THREAD(thread_id)->status=THREAD_EXITED;    co_broadcast(& OBJ2THREAD(thread_id)->status_change);       free((char *)data); /* Moved by per, to avoid some bugs.... */    UNSETJMP(back);       THREADS_FPRINTF(0, (stderr,"THREADS_ALLOW() Thread %08x done\n",    (unsigned int)thread_id));    +  cleanup_interpret(); +  DO_IF_DMALLOC( +  SWAP_OUT_THREAD(OBJ2THREAD(thread_id)); /* de-Init struct */ +  OBJ2THREAD(thread_id)->swapped=0; +  )    thread_table_delete(thread_id);    free_object(thread_id);    thread_id=0; -  cleanup_interpret(); +     num_threads--;    if(!num_threads && threads_evaluator_callback)    {    remove_callback(threads_evaluator_callback);    threads_evaluator_callback=0;    }    mt_unlock(& interpreter_lock);    th_exit(0);    /* NOT_REACHED, but removes a warning */    return(NULL);
pike.git/src/threads.c:701: Inside #if defined(UNIX_THREADS)
   th_setconcurrency(c);   }   #endif      void f_this_thread(INT32 args)   {    pop_n_elems(args);    ref_push_object(thread_id);   }    - #define THIS_MUTEX ((struct mutex_storage *)(fp->current_storage)) + #define THIS_MUTEX ((struct mutex_storage *)(CURRENT_STORAGE))         /* Note:    * No reference is kept to the key object, it is destructed if the    * mutex is destructed. The key pointer is set to zero by the    * key object when the key is destructed.    */      struct mutex_storage   {
pike.git/src/threads.c:873:      void exit_mutex_obj(struct object *o)   {    THREADS_FPRINTF(1, (stderr, "DESTROYING MUTEX m:%08x\n",    (unsigned int)THIS_MUTEX));    if(THIS_MUTEX->key) destruct(THIS_MUTEX->key);    THIS_MUTEX->key=0;    co_destroy(& THIS_MUTEX->condition);   }    - #define THIS_KEY ((struct key_storage *)(fp->current_storage)) + #define THIS_KEY ((struct key_storage *)(CURRENT_STORAGE))   void init_mutex_key_obj(struct object *o)   {    THREADS_FPRINTF(1, (stderr, "KEY k:%08x, o:%08x\n",    (unsigned int)THIS_KEY, (unsigned int)thread_id));    THIS_KEY->mut=0;    add_ref(THIS_KEY->owner=thread_id);    THIS_KEY->initialized=1;   }      void exit_mutex_key_obj(struct object *o)
pike.git/src/threads.c:909:    if (THIS_KEY->owner) {    free_object(THIS_KEY->owner);    THIS_KEY->owner=0;    }    THIS_KEY->mut=0;    THIS_KEY->initialized=0;    co_signal(& mut->condition);    }   }    - #define THIS_COND ((COND_T *)(fp->current_storage)) + #define THIS_COND ((COND_T *)(CURRENT_STORAGE))   void f_cond_wait(INT32 args)   {    COND_T *c;    struct object *key;       if(args > 1) pop_n_elems(args - 1);       c=THIS_COND;       if(args > 0)
pike.git/src/threads.c:1075:    struct object *loc = clone_object(thread_local_prog,0);    ((struct thread_local *)loc->storage)->id = thread_local_id++;    pop_n_elems(args);    push_object(loc);   }      void f_thread_local_get(INT32 args)   {    struct svalue key;    struct mapping *m; -  key.u.integer = ((struct thread_local *)fp->current_storage)->id; +  key.u.integer = ((struct thread_local *)CURRENT_STORAGE)->id;    key.type = T_INT;    key.subtype = NUMBER_NUMBER;    pop_n_elems(args);    if(thread_id != NULL &&    (m = OBJ2THREAD(thread_id)->thread_local) != NULL)    mapping_index_no_free(sp++, m, &key);    else {    push_int(0);    sp[-1].subtype=NUMBER_UNDEFINED;    }   }      void f_thread_local_set(INT32 args)   {    struct svalue key;    struct mapping *m; -  key.u.integer = ((struct thread_local *)fp->current_storage)->id; +  key.u.integer = ((struct thread_local *)CURRENT_STORAGE)->id;    key.type = T_INT;    key.subtype = NUMBER_NUMBER;    if(args>1)    pop_n_elems(args-1);    else if(args<1)    error("Too few arguments to thread_local->set()\n");       if(thread_id == NULL)    error("Trying to set thread_local without thread!\n");