From 304e7fb703e7afddc1ef9be6aab6505e36b63b06 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Fri, 13 Mar 2009 10:45:16 +0000 Subject: Instead of a separate context-switch flag, set HpLim to zero This reduces the latency between a context-switch being triggered and the thread returning to the scheduler, which in turn should reduce the cost of the GC barrier when there are many cores. We still retain the old context_switch flag which is checked at the end of each block of allocation. The idea is that setting HpLim may fail if the the target thread is modifying HpLim at the same time; the context_switch flag is a fallback. It also allows us to "context switch soon" without forcing an immediate switch, which can be costly. --- rts/Interpreter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'rts/Interpreter.c') diff --git a/rts/Interpreter.c b/rts/Interpreter.c index 1b2d7303ed..1a6e9273e0 100644 --- a/rts/Interpreter.c +++ b/rts/Interpreter.c @@ -196,6 +196,9 @@ interpretBCO (Capability* cap) LOAD_STACK_POINTERS; + cap->r.rHpLim = (P_)1; // HpLim is the context-switch flag; when it + // goes to zero we must return to the scheduler. + // ------------------------------------------------------------------------ // Case 1: // @@ -1281,7 +1284,7 @@ run_BCO: // context switching: sometimes the scheduler can invoke // the interpreter with context_switch == 1, particularly // if the -C0 flag has been given on the cmd line. - if (cap->context_switch) { + if (cap->r.rHpLim == NULL) { Sp--; Sp[0] = (W_)&stg_enter_info; RETURN_TO_SCHEDULER(ThreadInterpret, ThreadYielding); } -- cgit v1.2.1