fix thread stuff (obs from Jiefei Ma).
This commit is contained in:
parent
5b8dc25eff
commit
79a1d3e13c
1
C/init.c
1
C/init.c
@ -1139,6 +1139,7 @@ InitThreadHandles(void)
|
||||
Yap_heap_regs->thread_handle[0].handle = pthread_self();
|
||||
pthread_mutex_init(&ThreadHandle[0].tlock, NULL);
|
||||
pthread_mutex_init(&ThreadHandle[0].tlock_status, NULL);
|
||||
Yap_heap_regs->thread_handle[0].tdetach = MkAtomTerm(AtomFalse);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -711,7 +711,8 @@ p_thread_atexit(void)
|
||||
{ /* '$thread_signal'(+P) */
|
||||
Term t;
|
||||
|
||||
if (ThreadHandle[worker_id].texit->Entry == MkAtomTerm(AtomTrue)) {
|
||||
if (!ThreadHandle[worker_id].texit ||
|
||||
ThreadHandle[worker_id].texit->Entry == MkAtomTerm(AtomTrue)) {
|
||||
return FALSE;
|
||||
}
|
||||
do {
|
||||
|
@ -45,10 +45,6 @@
|
||||
#define WL wl
|
||||
#endif
|
||||
#endif
|
||||
#ifdef THREADS
|
||||
#define ThreadHandlesLock Yap_heap_regs->thread_handles_lock
|
||||
#define ThreadHandle Yap_heap_regs->thread_handle
|
||||
#endif
|
||||
|
||||
#define Yap_HoleSize Yap_heap_regs->hole_size
|
||||
#define Yap_av Yap_heap_regs->av_
|
||||
@ -329,3 +325,8 @@
|
||||
#define ForeignCodeBase Yap_heap_regs->foreign_code_base
|
||||
#define ForeignCodeTop Yap_heap_regs->foreign_code_top
|
||||
#define ForeignCodeMax Yap_heap_regs->foreign_code_max
|
||||
|
||||
#ifdef THREADS
|
||||
#define ThreadHandlesLock Yap_heap_regs->thread_handles_lock
|
||||
#define ThreadHandle Yap_heap_regs->thread_handle
|
||||
#endif
|
||||
|
@ -44,10 +44,6 @@
|
||||
#ifndef WL
|
||||
#define WL wl
|
||||
#endif
|
||||
#endif
|
||||
#ifdef THREADS
|
||||
lockvar thread_handles_lock;
|
||||
struct thandle thread_handle[MAX_THREADS];
|
||||
#endif
|
||||
|
||||
UInt hole_size;
|
||||
@ -329,3 +325,8 @@
|
||||
ADDR foreign_code_base;
|
||||
ADDR foreign_code_top;
|
||||
ADDR foreign_code_max;
|
||||
|
||||
#ifdef THREADS
|
||||
lockvar thread_handles_lock;
|
||||
struct thandle thread_handle[MAX_THREADS];
|
||||
#endif
|
||||
|
@ -45,10 +45,6 @@
|
||||
#define WL wl
|
||||
#endif
|
||||
#endif
|
||||
#ifdef THREADS
|
||||
INIT_LOCK(Yap_heap_regs->thread_handles_lock);
|
||||
InitThreadHandles();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -329,3 +325,8 @@
|
||||
Yap_heap_regs->foreign_code_base = NULL;
|
||||
Yap_heap_regs->foreign_code_top = NULL;
|
||||
Yap_heap_regs->foreign_code_max = NULL;
|
||||
|
||||
#ifdef THREADS
|
||||
INIT_LOCK(Yap_heap_regs->thread_handles_lock);
|
||||
InitThreadHandles();
|
||||
#endif
|
||||
|
@ -45,10 +45,6 @@
|
||||
#define WL wl
|
||||
#endif
|
||||
#endif
|
||||
#ifdef THREADS
|
||||
REINIT_LOCK(Yap_heap_regs->thread_handles_lock);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -329,3 +325,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef THREADS
|
||||
REINIT_LOCK(Yap_heap_regs->thread_handles_lock);
|
||||
|
||||
#endif
|
||||
|
@ -46,10 +46,6 @@ worker_local wl WorkerLocak void void
|
||||
#define WL wl
|
||||
#endif
|
||||
#endif
|
||||
#ifdef THREADS
|
||||
lockvar thread_handles_lock ThreadHandlesLock MkLock
|
||||
struct thandle thread_handle[MAX_THREADS] ThreadHandle InitThreadHandles() void
|
||||
#endif
|
||||
|
||||
/* memory management */
|
||||
UInt hole_size Yap_HoleSize void void
|
||||
@ -377,3 +373,9 @@ void *foreign_code_loaded ForeignCodeLoaded =NULL RestoreForeignCode()
|
||||
ADDR foreign_code_base ForeignCodeBase =NULL void
|
||||
ADDR foreign_code_top ForeignCodeTop =NULL void
|
||||
ADDR foreign_code_max ForeignCodeMax =NULL void
|
||||
|
||||
/* Threads Array */
|
||||
#ifdef THREADS
|
||||
lockvar thread_handles_lock ThreadHandlesLock MkLock
|
||||
struct thandle thread_handle[MAX_THREADS] ThreadHandle InitThreadHandles() void
|
||||
#endif
|
||||
|
@ -41,8 +41,10 @@ volatile(P) :-
|
||||
:- initialization('$init_thread0').
|
||||
|
||||
'$init_thread0' :-
|
||||
'$no_threads', !,
|
||||
recorda('$thread_alias', [0|main], _).
|
||||
recorda('$thread_alias', [0|main], _),
|
||||
fail.
|
||||
'$init_thread0' :-
|
||||
'$no_threads', !.
|
||||
'$init_thread0' :-
|
||||
recorda('$thread_defaults', [0, 0, 0, false, true], _),
|
||||
'$create_thread_mq'(0),
|
||||
@ -863,7 +865,7 @@ thread_property(Id, Prop) :-
|
||||
; Status = running
|
||||
).
|
||||
'$thread_property'(Id, detached(Detached)) :-
|
||||
'$thread_detached'(Id,Detached).
|
||||
( '$thread_detached'(Id,Detached) -> true ; Detached = false ).
|
||||
'$thread_property'(Id, at_exit(M:G)) :-
|
||||
'$thread_run_at_exit'(G,M).
|
||||
'$thread_property'(Id, InfoSize) :-
|
||||
|
Reference in New Issue
Block a user