Update of /cvsroot/sbcl/sbcl/src/code
In directory sc8-pr-cvs1:/tmp/cvs-serv25804/src/code
Modified Files:
Tag: atropos-branch
gc.lisp
Log Message:
0.8.3.95.atropos.2
Rewrote the strange locking stuff in SUB-GC so that I can
understand it again: as a side effect, my newest thread/gc
torture test works again
OTOH, the final test in threads.impure.lisp was once observed
to break with this code, but who's to know if that's new?
Index: gc.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/gc.lisp,v
retrieving revision 1.51
retrieving revision 1.51.2.1
diff -u -d -r1.51 -r1.51.2.1
--- gc.lisp 29 Sep 2003 15:35:30 -0000 1.51
+++ gc.lisp 30 Sep 2003 15:49:11 -0000 1.51.2.1
@@ -237,25 +237,21 @@
(defvar *gc-mutex* (sb!thread:make-mutex :name "GC Mutex"))
(defun sub-gc (&key (gen 0) &aux (pre-gc-dynamic-usage (dynamic-usage)))
- (when *already-in-gc* (return-from sub-gc nil))
- (setf *need-to-collect-garbage* t)
- (when (zerop *gc-inhibit*)
- (sb!thread:with-recursive-lock (*gc-mutex*)
- (let ((*already-in-gc* t))
- (without-interrupts
- (gc-stop-the-world)
- #+nil
- (dolist (h *before-gc-hooks*)
- (carefully-funcall h))
- (collect-garbage gen)
- (incf *n-bytes-freed-or-purified*
- (max 0 (- pre-gc-dynamic-usage (dynamic-usage))))
- (setf *need-to-collect-garbage* nil)
-
- (gc-start-the-world)))
- (scrub-control-stack))
- (dolist (h *after-gc-hooks*)
- (carefully-funcall h)))
+ ;; catch attempts to gc recursively or during post-hooks and ignore them
+ (when (sb!thread::mutex-value *gc-mutex*) (return-from sub-gc nil))
+ (sb!thread:with-mutex (*gc-mutex* :wait-p nil)
+ (setf *need-to-collect-garbage* t)
+ (when (zerop *gc-inhibit*)
+ (without-interrupts
+ (gc-stop-the-world)
+ (collect-garbage gen)
+ (incf *n-bytes-freed-or-purified*
+ (max 0 (- pre-gc-dynamic-usage (dynamic-usage))))
+ (setf *need-to-collect-garbage* nil)
+ (gc-start-the-world))
+ (scrub-control-stack)
+ (setf *need-to-collect-garbage* nil)
+ (dolist (h *after-gc-hooks*) (carefully-funcall h))))
(values))
|