0.8.6.16
authorDaniel Barlow <dan@telent.net>
Sat, 29 Nov 2003 23:54:20 +0000 (23:54 +0000)
committerDaniel Barlow <dan@telent.net>
Sat, 29 Nov 2003 23:54:20 +0000 (23:54 +0000)
Tidy up a bit

GET-FOREGROUND now prints 'Resuming thread n' messages on
thread swith, to make it slightly harder to get lost

THREAD-REPL-PROMPT-FUN goes away: it was a kludge anyway and
most of what it did is done in the standard prompt function

gc_thread_pid no more.  Don't need sys/ptrace.h.  Delete call
to mach_init() which doesn't exist anyway.  Ignore
uninteresting signals in parent thread, and lose
parent_sighandler

src/code/target-thread.lisp
src/runtime/gc.h
src/runtime/runtime.c
version.lisp-expr

index 2390437..1d38f08 100644 (file)
@@ -389,27 +389,25 @@ interactive."
                     (session-interactive-threads *session*))))
     (get-foreground)))
 
-(defun thread-repl-prompt-fun (out-stream)
-  (get-foreground)
-  (let ((stopped-threads (cdr (session-interactive-threads *session*))))
-    (when stopped-threads
-      (format out-stream "~{~&Thread ~A suspended~}~%" stopped-threads))
-    (sb!impl::repl-prompt-fun out-stream)))
 
 (defun get-foreground ()
-  (loop
-   (with-mutex ((session-lock *session*))
-     (let ((tid (current-thread-id))
-          (int-t (session-interactive-threads *session*)))
-       (when (eql (car int-t) tid)
-        (sb!sys:enable-interrupt sb!unix:sigint #'sb!unix::sigint-handler)
-        (return-from get-foreground t))
-       (unless (member tid int-t)
-        (setf (cdr (last int-t))
-              (list tid)))
-       (condition-wait
-       (session-interactive-threads-queue *session*)
-       (session-lock *session*))))))
+  (let ((was-foreground t))
+    (loop
+     (with-mutex ((session-lock *session*))
+       (let ((tid (current-thread-id))
+            (int-t (session-interactive-threads *session*)))
+        (when (eql (car int-t) tid)
+          (unless was-foreground
+            (format *query-io* "Resuming thread ~A~%" tid))
+          (sb!sys:enable-interrupt sb!unix:sigint #'sb!unix::sigint-handler)
+          (return-from get-foreground t))
+        (setf was-foreground nil)
+        (unless (member tid int-t)
+          (setf (cdr (last int-t))
+                (list tid)))
+        (condition-wait
+         (session-interactive-threads-queue *session*)
+         (session-lock *session*)))))))
 
 (defun release-foreground (&optional next)
   "Background this thread.  If NEXT is supplied, arrange for it to have the foreground next"
index 4760349..c27ab79 100644 (file)
@@ -28,5 +28,4 @@ extern void set_auto_gc_trigger(os_vm_size_t usage);
 extern void clear_auto_gc_trigger(void);
 
 extern int maybe_gc_pending;
-extern int gc_thread_pid;
 #endif /* _GC_H_ */
index 6799033..115a24b 100644 (file)
@@ -26,9 +26,6 @@
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <signal.h>
-#ifdef LISP_FEATURE_SB_THREAD
-#include <sys/ptrace.h>
-#endif
 #include <sched.h>
 #include <errno.h>
 
@@ -189,7 +186,6 @@ More information about SBCL is available at <http://sbcl.sourceforge.net/>.\n\
 ", SBCL_VERSION_STRING);
 }
 \f
-int gc_thread_pid;
 FILE *stdlog;
 
 \f
@@ -318,9 +314,6 @@ main(int argc, char *argv[], char *envp[])
        fflush(stdout);
     }
 
-#ifdef MACH
-    mach_init();
-#endif
 #if defined(SVR4) || defined(__linux__)
     tzset();
 #endif
@@ -357,24 +350,15 @@ main(int argc, char *argv[], char *envp[])
     create_thread(initial_function);
     /* in a unithread build, create_thread never returns */
 #ifdef LISP_FEATURE_SB_THREAD
-    gc_thread_pid=getpid();
     parent_loop();
 #endif
 }
 
-static void parent_sighandler(int signum,siginfo_t *info, void *void_context) 
-{
-#if 0
-    os_context_t *context = (os_context_t*)void_context;
-    fprintf(stderr,
-           "parent thread got signal %d from %d, maybe_gc_pending=%d\n",
-           signum, info->si_pid,
-           maybe_gc_pending);
-#endif
-}
-
 #ifdef LISP_FEATURE_SB_THREAD
-int show_thread_exit=0;
+
+/* this is being pared down as time goes on; eventually we want to get
+ * to the point that we have no parent loop at all and the parent
+ * thread runs Lisp just like any other */
 
 static void /* noreturn */ parent_loop(void)
 {
@@ -384,41 +368,25 @@ static void /* noreturn */ parent_loop(void)
     pid_t pid=0;
 
     sigemptyset(&sigset);
-
-    sigaddset(&sigset, SIGCHLD);
-    sigaddset(&sigset, SIG_THREAD_EXIT);
-    sigprocmask(SIG_UNBLOCK,&sigset,0);
-    sa.sa_handler=parent_sighandler;
-    sa.sa_mask=sigset;
-    sa.sa_flags=SA_SIGINFO;
-    sigaction(SIGCHLD, &sa, 0);
-
-    sigemptyset(&sigset);
     sa.sa_handler=SIG_IGN;
     sa.sa_mask=sigset;
     sa.sa_flags=0;
-    sigaction(SIGINT, &sa, 0);
+    sigaction(SIGINT, &sa, 0);         /* ^c should go to the lisp thread instead */
     sigaction(SIG_THREAD_EXIT, &sa, 0);
+    sigaction(SIGCHLD, &sa, 0);
 
     while(!all_threads) {
        sched_yield();
     }
     while(all_threads && (pid=waitpid(-1,&status,__WALL))) {
        struct thread *th;
-       int real_errno=errno;
        if(pid==-1) {
-           if(real_errno == EINTR) {
-               continue;
-           }
-           if(real_errno == ECHILD) break;
-           fprintf(stderr,"waitpid: %s\n",strerror(real_errno));
-           continue;
+           if(errno == EINTR) continue;
+           fprintf(stderr,"waitpid: %s\n",strerror(errno));
        }
-       if(WIFEXITED(status) || WIFSIGNALED(status)) {
+       else if(WIFEXITED(status) || WIFSIGNALED(status)) {
            th=find_thread_by_pid(pid);
            if(!th) continue;
-           if(show_thread_exit)
-               fprintf(stderr,"waitpid : child %d %x exited \n", pid,th);
            destroy_thread(th);
            if(!all_threads) break;
        }
index 9646056..8e708ae 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.8.6.15"
+"0.8.6.16"