;;; -*- Mode:Lisp; Readtable:CL; Package:USER; Base:10; Patch-File:T -*-
;;; Patch file for System version 123.208
;;; Reason:
;;;  (gc:gc-off) should wait for the Garbage Collector process to finish
;;;  its current cycle and suspend itself, rather than just bludgeoning
;;;  it into submission.
;;; Written 24-Feb-88 16:00:05 by pld at site Gigamos Cambridge
;;; while running on Jack Flanders from band 2
;;; with Experimental System 123.207, Experimental Local-File 73.3, Experimental FILE-Server 22.1, Experimental Unix-Interface 11.0, Experimental KERMIT 34.3, Experimental ZMail 71.0, Experimental Lambda-Diag 15.0, Experimental Tape 21.1, microcode 1755, SDU Boot Tape 3.12, SDU ROM 8.

; From modified file DJ: L.SYS2; GC.LISP#349 at 24-Feb-88 16:29:49
#10R GARBAGE-COLLECTOR#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "GARBAGE-COLLECTOR")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: SYS2; GC  "

(defun gc-off (&optional &key reset)
  (without-flipping
    (when ( *oldspace-words* 0)
      (tv:notify () "GC: Reclaiming oldspace before turning GC off.")
      (reclaim-oldspace :batch)))
  (when (and (boundp '*gc-process*) *gc-process*)
    (when (eq *gc-process-control* :active)
      (setq *gc-process-control* :suspend)
      (process-wait "Suspended GC" #'(lambda () (eq *gc-process-control* :suspended))))
    (without-interrupts
      (when reset
	(send *gc-process* :reset))
      (send *gc-process* :arrest-reason :gc-stopped)
      (send *gc-process* :revoke-run-reason :enable)))
  t)

))
