From b54dd9e2b94bc8687226e688cbc879983dab2e16 Mon Sep 17 00:00:00 2001 From: vsc Date: Thu, 4 May 2006 18:46:50 +0000 Subject: [PATCH] more thread stuff git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1631 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/threads.c | 10 ++++++++++ C/tracer.c | 2 ++ changes-5.1.html | 2 ++ docs/yap.tex | 6 ++++++ pl/threads.yap | 9 +++++++-- 5 files changed, 27 insertions(+), 2 deletions(-) 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: