Branch: Tag:

1996-10-11

1996-10-11 07:47:03 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

mutex locks are now initialized

Rev: src/threads.c:1.5

10: Inside #if defined(_REENTRANT)
     #ifdef _REENTRANT    - MUTEX_T interpreter_lock; + MUTEX_T interpreter_lock = PTHREAD_MUTEX_INITIALIZER;   struct program *mutex_key = 0;   struct program *thread_id_prog = 0;   pthread_attr_t pattr;
26: Inside #if defined(_REENTRANT)
   struct thread_starter arg = *(struct thread_starter *)data;    JMP_BUF back;    INT32 args; +     free((char *)data); -  +  +  if(args=mt_lock( & interpreter_lock)) +  fatal("Failed to lock interpreter, errno %d\n",args); +     args=arg.args->size; -  mt_lock( & interpreter_lock); +     init_interpreter();       thread_id=arg.id;
44: Inside #if defined(_REENTRANT)
   } else {    push_array_items(arg.args);    arg.args=0; -  f_call_function(args); -  +     }       UNSETJMP(back);       destruct(thread_id); -  +     free_object(thread_id);    thread_id=0;   
60: Inside #if defined(_REENTRANT)
   th_exit(0);   }    +    void f_thread_create(INT32 args)   { -  struct thread_starter *arg; +     pthread_t dummy; -  +  struct thread_starter *arg;    int tmp;    arg=ALLOC_STRUCT(thread_starter);    arg->args=aggregate_array(args);
122:    int initialized;   };    - static MUTEX_T mutex_kluge; + static MUTEX_T mutex_kluge = PTHREAD_MUTEX_INITIALIZER;      #define OB2KEY(X) ((struct key_storage *)((X)->storage))