Index: /branches/working-0711/ccl/level-1/l1-lisp-threads.lisp
===================================================================
--- /branches/working-0711/ccl/level-1/l1-lisp-threads.lisp	(revision 12798)
+++ /branches/working-0711/ccl/level-1/l1-lisp-threads.lisp	(revision 12799)
@@ -485,4 +485,5 @@
 ;;; This doesn't quite activate the thread; see PROCESS-TCR-ENABLE.
 (defun %activate-tcr (tcr termination-semaphore allocation-quantum)
+  (declare (ignore termination-semaphore))
   (if (and tcr (not (eql 0 tcr)))
     (with-macptrs (tcrp)
@@ -490,8 +491,4 @@
       (setf (%get-natural tcrp target::tcr.log2-allocation-quantum)
             (or allocation-quantum (default-allocation-quantum)))
-      (setf (%get-ptr tcrp target::tcr.termination-semaphore)
-            (if termination-semaphore
-              (semaphore-value termination-semaphore)
-              (%null-ptr)))
       t)))
                          
@@ -1115,3 +1112,7 @@
 (defun %foreign-thread-terminate ()
   (let* ((proc *current-process*))
-    (when proc (remove-from-all-processes proc))))
+    (when proc
+      (remove-from-all-processes proc)
+      (let* ((ts (process-termination-semaphore proc)))
+        (when ts (signal-semaphore ts))))))
+
Index: /branches/working-0711/ccl/level-1/l1-processes.lisp
===================================================================
--- /branches/working-0711/ccl/level-1/l1-processes.lisp	(revision 12798)
+++ /branches/working-0711/ccl/level-1/l1-processes.lisp	(revision 12799)
@@ -319,13 +319,5 @@
     ))
 
-(defmethod (setf process-termination-semaphore) :after (new (p process))
-  (with-macptrs (tcrp)
-    (%setf-macptr-to-object tcrp (process-tcr p))
-    (unless (%null-ptr-p tcrp)
-      (setf (%get-ptr tcrp target::tcr.termination-semaphore)
-            (if new
-              (semaphore-value new)
-              (%null-ptr))))
-    new))
+
 
 (defun process-resume (p)
@@ -418,5 +410,4 @@
 ;;; Separated from run-process-initial-form just so I can change it easily.
 (defun process-initial-form-exited (process kill)
-  ;; Enter the *initial-process* and have it finish us up
   (without-interrupts
    (if (eq kill :shutdown)
@@ -424,4 +415,6 @@
        (setq *whostate* "Shutdown")
        (add-to-shutdown-processes process)))
+   (let* ((semaphore (process-termination-semaphore process)))
+     (when semaphore (signal-semaphore semaphore)))
    (maybe-finish-process-kill process kill)))
 
Index: /branches/working-0711/ccl/lisp-kernel/thread_manager.c
===================================================================
--- /branches/working-0711/ccl/lisp-kernel/thread_manager.c	(revision 12798)
+++ /branches/working-0711/ccl/lisp-kernel/thread_manager.c	(revision 12799)
@@ -1381,5 +1381,4 @@
 
   area *vs, *ts, *cs;
-  void *termination_semaphore;
   
   if (current == NULL) {
@@ -1424,5 +1423,4 @@
     tcr->osid = 0;
     tcr->interrupt_pending = 0;
-    termination_semaphore = tcr->termination_semaphore;
     tcr->termination_semaphore = NULL;
 #ifdef HAVE_TLS
@@ -1439,7 +1437,4 @@
 #endif
     UNLOCK(lisp_global(TCR_AREA_LOCK),current);
-    if (termination_semaphore) {
-      SEM_RAISE(termination_semaphore);
-    }
   } else {
     tsd_set(lisp_global(TCR_KEY), TCR_TO_TSD(tcr));
