Skip to content
Snippets Groups Projects
Commit b1b51f52 authored by Fredrik Hübinette (Hubbe)'s avatar Fredrik Hübinette (Hubbe)
Browse files

mutex locks are now initialized

Rev: src/threads.c:1.5
parent aef30b92
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ struct object *thread_id; ...@@ -10,7 +10,7 @@ struct object *thread_id;
#ifdef _REENTRANT #ifdef _REENTRANT
MUTEX_T interpreter_lock; MUTEX_T interpreter_lock = PTHREAD_MUTEX_INITIALIZER;
struct program *mutex_key = 0; struct program *mutex_key = 0;
struct program *thread_id_prog = 0; struct program *thread_id_prog = 0;
pthread_attr_t pattr; pthread_attr_t pattr;
...@@ -26,9 +26,13 @@ void *new_thread_func(void * data) ...@@ -26,9 +26,13 @@ void *new_thread_func(void * data)
struct thread_starter arg = *(struct thread_starter *)data; struct thread_starter arg = *(struct thread_starter *)data;
JMP_BUF back; JMP_BUF back;
INT32 args; INT32 args;
free((char *)data); free((char *)data);
if(args=mt_lock( & interpreter_lock))
fatal("Failed to lock interpreter, errno %d\n",args);
args=arg.args->size; args=arg.args->size;
mt_lock( & interpreter_lock);
init_interpreter(); init_interpreter();
thread_id=arg.id; thread_id=arg.id;
...@@ -44,13 +48,12 @@ void *new_thread_func(void * data) ...@@ -44,13 +48,12 @@ void *new_thread_func(void * data)
} else { } else {
push_array_items(arg.args); push_array_items(arg.args);
arg.args=0; arg.args=0;
f_call_function(args);
} }
UNSETJMP(back); UNSETJMP(back);
destruct(thread_id); destruct(thread_id);
free_object(thread_id); free_object(thread_id);
thread_id=0; thread_id=0;
...@@ -60,10 +63,11 @@ void *new_thread_func(void * data) ...@@ -60,10 +63,11 @@ void *new_thread_func(void * data)
th_exit(0); th_exit(0);
} }
void f_thread_create(INT32 args) void f_thread_create(INT32 args)
{ {
struct thread_starter *arg;
pthread_t dummy; pthread_t dummy;
struct thread_starter *arg;
int tmp; int tmp;
arg=ALLOC_STRUCT(thread_starter); arg=ALLOC_STRUCT(thread_starter);
arg->args=aggregate_array(args); arg->args=aggregate_array(args);
...@@ -122,7 +126,7 @@ struct key_storage ...@@ -122,7 +126,7 @@ struct key_storage
int initialized; int initialized;
}; };
static MUTEX_T mutex_kluge; static MUTEX_T mutex_kluge = PTHREAD_MUTEX_INITIALIZER;
#define OB2KEY(X) ((struct key_storage *)((X)->storage)) #define OB2KEY(X) ((struct key_storage *)((X)->storage))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment