This file is indexed.

/usr/lib/s9fes/threads.scm is in scheme9 2010.11.13-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
; Scheme 9 from Empty Space, Function Library
; By Nils M Holm, 2010
; See the LICENSE file of the S9fES package for terms of use
;
; (thread-create procedure^0)  ==>  unspecific
; (thread-yield)               ==>  unspecific
; (thread-exit)                ==>  unspecific
; (thread-start)               ==>  unspecific
;
; (load-from-library "threads.scm")
;
; Run cooperative threads. THREAD-CREATE adds a new procedure to be run
; as a thread. THREAD-YIELD is used in a thread to pass control to another
; thread. A thread that does no longer have any work to do should exit
; by calling THREAD-EXIT. If it simply exits without announcing this,
; the scheduler will exit, too. THREAD-START starts all threads created
; earlier with THREAD-CREATE. When THREAD-EXIT is called by the last
; thread in the queue, the scheduler will also exit.
;
; (Example): (define (p n x)
;              (lambda ()
;                (do ((n n (- n 1)))
;                    ((negative? n)
;                      (thread-exit))
;                  (display x)
;                  (thread-yield))))
;
;            (thread-create (p 100 "A"))
;            (thread-create (p 200 "B"))
;            (thread-start)

(load-from-library "queue.scm")

(define *thread-queue* (make-queue))

(define (queue-thread thread)
  (queue *thread-queue* thread))

(define (unqueue-thread)
  (unqueue *thread-queue*))

(define thread-create
  (let ((queue-thread queue-thread))
    (lambda (thunk)
      (call/cc
        (lambda (k)
          (queue-thread k)
          (thunk))))))

(define thread-yield
  (let ((queue-thread   queue-thread)
        (unqueue-thread unqueue-thread))
    (lambda ()
      (call/cc
        (lambda (k)
          (queue-thread k)
          ((unqueue-thread) #t))))))

(define thread-exit
  (let ((queue-thread queue-thread))
    (lambda ()
      (if (not (queue-empty? *thread-queue*))
          ((unqueue-thread) #t)))))

(define thread-start thread-exit)