From 4d1e3fe83816eff4c0b914b7e2a008c81e73f682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20F=2E=20Wittenberger?= Date: Wed, 19 Dec 2018 17:52:15 +0100 Subject: [PATCH] Use dedicated thread instead of forcing primordial for signals. Note: force-primordial is a misnomer now. Left alone to keep tests working. TBD: Hide the identifyer and remove those tests. --- scheduler.scm | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/scheduler.scm b/scheduler.scm index df4db928..63bced60 100644 --- a/scheduler.scm +++ b/scheduler.scm @@ -233,10 +233,29 @@ EOF [(eq? (##sys#slot nt 3) 'ready) (switch nt)] [else (loop2)] ) ) ) ) ) ) -(define (##sys#force-primordial) - (dbg "primordial thread forced due to interrupt") - (##sys#setislot ##sys#primordial-thread 13 #f) - (##sys#thread-unblock! ##sys#primordial-thread) ) +(define ##sys#force-primordial + (let* ((thread #f) + (install! + (lambda () + (set! thread + (##sys#make-thread + (lambda () + (let loop () + ;; inline from (thread-suspend! (current-thread)) + (##sys#setslot thread 3 'suspended) + (##sys#call-with-current-continuation + (lambda (return) + (##sys#setslot thread 1 (lambda () (return (##core#undefined)))) + (##sys#schedule) ) ) + (loop))) + 'suspended 'signal-handler 10))))) + (install!) + (lambda () + (dbg "signal thread forced due to interrupt") + ;; inline from thread-resume! + (unless (eq? (##sys#slot thread 3) 'suspended) (install!)) + (##sys#setslot thread 3 'ready) + (##sys#add-to-ready-queue thread))) ) (define ready-queue-head '()) (define ready-queue-tail '()) -- 2.11.0