more thread stuff
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1631 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
89d8c4d035
commit
b54dd9e2b9
10
C/threads.c
10
C/threads.c
@ -338,6 +338,15 @@ p_thread_set_concurrency(void)
|
||||
return Yap_unify(ARG1, MkIntegerTerm(cur));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_yield(void)
|
||||
{
|
||||
if (sched_yield() != 0) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_valid_thread(void)
|
||||
{
|
||||
@ -545,6 +554,7 @@ void Yap_InitThreadPreds(void)
|
||||
Yap_InitCPred("$thread_self", 1, p_thread_self, SafePredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$thread_join", 1, p_thread_join, HiddenPredFlag);
|
||||
Yap_InitCPred("$thread_destroy", 1, p_thread_destroy, HiddenPredFlag);
|
||||
Yap_InitCPred("thread_yield", 0, p_thread_yield, 0);
|
||||
Yap_InitCPred("$detach_thread", 1, p_thread_detach, HiddenPredFlag);
|
||||
Yap_InitCPred("$thread_exit", 0, p_thread_exit, HiddenPredFlag);
|
||||
Yap_InitCPred("thread_setconcurrency", 2, p_thread_set_concurrency, 0);
|
||||
|
@ -161,6 +161,8 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
LOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
sc = Yap_heap_regs;
|
||||
vsc_count++;
|
||||
if (vsc_count < 81000)
|
||||
return;
|
||||
#ifdef COMMENTED
|
||||
if (worker_id != 04 || worker_id != 03) return;
|
||||
// if (vsc_count == 218280)
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
<h2>Yap-5.1.2:</h2>
|
||||
<ul>
|
||||
<li> NEW: thread_yield/0 (request Paulo Moura).</li>
|
||||
<li> FIXED: current_thread was not returning aliases (obs Paulo Moura).</li>
|
||||
<li> FIXED: AuxSp was not properly initialised for new threads (obs Paulo Moura).</li>
|
||||
<li> FIXED: recusive indexing over unbound compound terms was broken
|
||||
(obs Ricardo Lopes).</li>
|
||||
|
@ -10033,6 +10033,12 @@ normally and detach themselves just before completion. This way they
|
||||
leave no traces on normal completion and their reason for failure can be
|
||||
inspected.
|
||||
|
||||
@item thread_yield
|
||||
@findex thread_yield/0
|
||||
@snindex thread_yield/0
|
||||
@cnindex thread_yield/0
|
||||
Voluntarily relinquish the processor.
|
||||
|
||||
@item thread_exit(+@var{Term})
|
||||
@findex thread_exit/1
|
||||
@snindex thread_exit/1
|
||||
|
@ -170,9 +170,10 @@ current_thread(Tid, Status) :-
|
||||
current_thread(Tid, Status) :-
|
||||
'$do_error'(type_error(integer,Tid),current_thread(Tid, Status)).
|
||||
|
||||
'$cur_threads'(Tid, Tid, Status) :-
|
||||
'$cur_threads'(Tid, TidName, Status) :-
|
||||
'$valid_thread'(Tid),
|
||||
'$thr_status'(Tid, Status).
|
||||
'$thr_status'(Tid, Status),
|
||||
'$tid_to_alias'(Tid,TidName).
|
||||
'$cur_threads'(Tid, TidF, Status) :-
|
||||
'$valid_thread'(Tid),
|
||||
Tid1 is Tid+1,
|
||||
@ -182,6 +183,10 @@ current_thread(Tid, Status) :-
|
||||
recorded('$thread_exit_status', [Tid|Status], _), !.
|
||||
'$thr_status'(_, running).
|
||||
|
||||
'$tid_to_alias'(Tid,TidName) :-
|
||||
recorded('$thread_alias', [Tid|TidName], _), !.
|
||||
'$tid_to_alias'(Tid,Tid).
|
||||
|
||||
|
||||
mutex_create(V) :-
|
||||
var(V), !,
|
||||
|
Reference in New Issue
Block a user