diff --git a/C/threads.c b/C/threads.c
index 553ae7611..6a0b33da6 100644
--- a/C/threads.c
+++ b/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);
diff --git a/C/tracer.c b/C/tracer.c
index acd131f7d..319b8093e 100644
--- a/C/tracer.c
+++ b/C/tracer.c
@@ -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)
diff --git a/changes-5.1.html b/changes-5.1.html
index d908d2c6d..56c804c6a 100644
--- a/changes-5.1.html
+++ b/changes-5.1.html
@@ -16,6 +16,8 @@
Yap-5.1.2:
+- NEW: thread_yield/0 (request Paulo Moura).
+- FIXED: current_thread was not returning aliases (obs Paulo Moura).
- FIXED: AuxSp was not properly initialised for new threads (obs Paulo Moura).
- FIXED: recusive indexing over unbound compound terms was broken
(obs Ricardo Lopes).
diff --git a/docs/yap.tex b/docs/yap.tex
index 0d81ed15e..4dcffb197 100644
--- a/docs/yap.tex
+++ b/docs/yap.tex
@@ -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
diff --git a/pl/threads.yap b/pl/threads.yap
index 826965f81..9d3699b30 100644
--- a/pl/threads.yap
+++ b/pl/threads.yap
@@ -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), !,