summaryrefslogtreecommitdiff
path: root/tests/gc-threads.impure.lisp
blob: a2bf0e58cb93154fe04ea9e88c89af92b27e5767 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#-sb-thread (invoke-restart 'run-tests::skip-file)

(with-test (:name (:two-threads-running-gc)
                  :broken-on :sb-safepoint)
  (let (a-done b-done)
    (make-join-thread (lambda ()
                        (dotimes (i 100)
                          (sb-ext:gc) (princ "\\") (force-output))
                        (setf a-done t)))
    (make-join-thread (lambda ()
                        (dotimes (i 25)
                          (sb-ext:gc :full t)
                          (princ "/") (force-output))
                        (setf b-done t)))
    (loop
      (when (and a-done b-done) (return))
      (sleep 1))))

(defun waste (&optional (n 1000))
  (loop repeat n do (test-util:opaque-identity (make-string 16384))))

(compile 'waste)

(with-test (:name (:one-thread-runs-gc-while-other-conses)
                  :broken-on :win32)
  (loop for i below 100 do
        (princ "!")
        (force-output)
        (make-join-thread
         #'(lambda ()
             (waste)))
        (waste)
        (sb-ext:gc)))

(defparameter *aaa* nil)
(with-test (:name (:one-thread-runs-gc-while-other-conses :again)
            :broken-on :win32)
  (loop for i below 100 do
        (princ "!")
        (force-output)
        (make-join-thread
         #'(lambda ()
             (let ((*aaa* (waste)))
               (waste))))
        (let ((*aaa* (waste)))
          (waste))
        (sb-ext:gc)))