Skip to content

Commit 8455126

Browse files
committed
c3 41-43
1 parent 16a6200 commit 8455126

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

src/c3_41.scm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
; another stupid question.
2+
; The chapter is awful

src/c3_42.scm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
; this seems like an implementation dependent problem
2+
; what will happend may depend on the implementation of serializer.

src/c3_43.scm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
; My answer is on http://sicp.readthedocs.org/en/latest/chp3/43.html

src/lib/concurrency.scm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,14 @@
55

66
(define (parallel-execute . args)
77
(for-each fork-thread args))
8+
9+
(define (make-serializer)
10+
(let ((mutex (make-mutex)))
11+
(lambda (p)
12+
(define (serialized-p . args)
13+
(mutex 'acquire)
14+
(let ((val (apply p args)))
15+
(mutex 'release)
16+
val))
17+
serialized-p)))
818
)

0 commit comments

Comments
 (0)