Merge branch 'master' of ssh://yap.git.sourceforge.net/gitroot/yap/yap-6.3

This commit is contained in:
Vitor Santos Costa 2012-10-19 18:12:06 +01:00
commit e92b8791c5
2 changed files with 7 additions and 7 deletions

View File

@ -62,15 +62,15 @@ allocate_new_tid(void)
if (new_worker_id >= MAX_THREADS) { if (new_worker_id >= MAX_THREADS) {
new_worker_id = -1; new_worker_id = -1;
} else if (!Yap_local[new_worker_id]) { } else if (!Yap_local[new_worker_id]) {
DEBUG_TLOCK_ACCESS(new_worker_id, 0);
if (!Yap_InitThread(new_worker_id)) { if (!Yap_InitThread(new_worker_id)) {
return -1; return -1;
} }
pthread_mutex_lock(&(REMOTE_ThreadHandle(new_worker_id).tlock)); pthread_mutex_lock(&(REMOTE_ThreadHandle(new_worker_id).tlock));
DEBUG_TLOCK_ACCESS(new_worker_id, 0);
REMOTE_ThreadHandle(new_worker_id).in_use = TRUE; REMOTE_ThreadHandle(new_worker_id).in_use = TRUE;
} else if (new_worker_id < MAX_THREADS) { } else if (new_worker_id < MAX_THREADS) {
DEBUG_TLOCK_ACCESS(new_worker_id, 0);
pthread_mutex_lock(&(REMOTE_ThreadHandle(new_worker_id).tlock)); pthread_mutex_lock(&(REMOTE_ThreadHandle(new_worker_id).tlock));
DEBUG_TLOCK_ACCESS(new_worker_id, 0);
REMOTE_ThreadHandle(new_worker_id).in_use = TRUE; REMOTE_ThreadHandle(new_worker_id).in_use = TRUE;
} else { } else {
new_worker_id = -1; new_worker_id = -1;
@ -406,8 +406,8 @@ p_thread_zombie_self( USES_REGS1 )
/* make sure the lock is available */ /* make sure the lock is available */
if (pthread_getspecific(Yap_yaamregs_key) == NULL) if (pthread_getspecific(Yap_yaamregs_key) == NULL)
return Yap_unify(MkIntegerTerm(-1), ARG1); return Yap_unify(MkIntegerTerm(-1), ARG1);
DEBUG_TLOCK_ACCESS(4, worker_id);
pthread_mutex_lock(&(LOCAL_ThreadHandle.tlock)); pthread_mutex_lock(&(LOCAL_ThreadHandle.tlock));
DEBUG_TLOCK_ACCESS(4, worker_id);
if (LOCAL_ActiveSignals &= YAP_ITI_SIGNAL) { if (LOCAL_ActiveSignals &= YAP_ITI_SIGNAL) {
DEBUG_TLOCK_ACCESS(5, worker_id); DEBUG_TLOCK_ACCESS(5, worker_id);
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
@ -498,9 +498,9 @@ Yap_thread_attach_engine(int wid)
pthread_mutex_lock(&(REMOTE_ThreadHandle(wid).tlock)); pthread_mutex_lock(&(REMOTE_ThreadHandle(wid).tlock));
*/ */
if (REMOTE_ThreadHandle(wid).ref_count ) { if (REMOTE_ThreadHandle(wid).ref_count ) {
DEBUG_TLOCK_ACCESS(8, wid);
REMOTE_ThreadHandle(wid).ref_count++; REMOTE_ThreadHandle(wid).ref_count++;
REMOTE_ThreadHandle(wid).pthread_handle = pthread_self(); REMOTE_ThreadHandle(wid).pthread_handle = pthread_self();
DEBUG_TLOCK_ACCESS(8, wid);
pthread_mutex_unlock(&(REMOTE_ThreadHandle(wid).tlock)); pthread_mutex_unlock(&(REMOTE_ThreadHandle(wid).tlock));
return TRUE; return TRUE;
} }
@ -516,8 +516,8 @@ Yap_thread_attach_engine(int wid)
Int Int
Yap_thread_detach_engine(int wid) Yap_thread_detach_engine(int wid)
{ {
DEBUG_TLOCK_ACCESS(10, wid);
pthread_mutex_lock(&(REMOTE_ThreadHandle(wid).tlock)); pthread_mutex_lock(&(REMOTE_ThreadHandle(wid).tlock));
DEBUG_TLOCK_ACCESS(10, wid);
//REMOTE_ThreadHandle(wid).pthread_handle = 0; //REMOTE_ThreadHandle(wid).pthread_handle = 0;
REMOTE_ThreadHandle(wid).ref_count--; REMOTE_ThreadHandle(wid).ref_count--;
pthread_setspecific(Yap_yaamregs_key, NULL); pthread_setspecific(Yap_yaamregs_key, NULL);
@ -529,8 +529,8 @@ Yap_thread_detach_engine(int wid)
Int Int
Yap_thread_destroy_engine(int wid) Yap_thread_destroy_engine(int wid)
{ {
DEBUG_TLOCK_ACCESS(10, wid);
pthread_mutex_lock(&(REMOTE_ThreadHandle(wid).tlock)); pthread_mutex_lock(&(REMOTE_ThreadHandle(wid).tlock));
DEBUG_TLOCK_ACCESS(10, wid);
if (REMOTE_ThreadHandle(wid).ref_count == 0) { if (REMOTE_ThreadHandle(wid).ref_count == 0) {
kill_thread_engine(wid, TRUE); kill_thread_engine(wid, TRUE);
return TRUE; return TRUE;

View File

@ -356,7 +356,7 @@ thread_exit(Term) :-
var(Term), !, var(Term), !,
'$do_error'(instantiation_error, thread_exit(Term)). '$do_error'(instantiation_error, thread_exit(Term)).
thread_exit(Term) :- thread_exit(Term) :-
'$close_thread'('$thread_finished'(exited(Term)), Detached). throw('$thread_finished'(exited(Term)).
'$run_at_thread_exit'(Id0) :- '$run_at_thread_exit'(Id0) :-
'$thread_run_at_exit'(G, M), '$thread_run_at_exit'(G, M),