Skip to content

Commit 772579e

Browse files
committed
Add implementation of exercise 3-39
1 parent c10c3be commit 772579e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

README.org

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
习题完成情况:
2626
- 章节一: 43/46
2727
- 章节二: 88/97
28-
- 章节三: 38/82
28+
- 章节三: 39/82
2929
- 章节四: TODO
3030
- 章节五: TODO
3131
* 运行

chapter3/exercise3-39.org

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#+LATEX_CLASS: ramsay-org-article
2+
#+LATEX_CLASS_OPTIONS: [oneside,A4paper,12pt]
3+
#+AUTHOR: Ramsay Leung
4+
5+
#+DATE: 2025-07-20 Sun 17:51
6+
#+begin_src scheme
7+
(parallel-execute
8+
(lambda ()
9+
(set! x ((s (lambda () (* x x))))))
10+
(s (lambda () (set! x (+ x 1)))))
11+
#+end_src
12+
13+
121 和 110 还可能出现
14+
15+
P2 的=(set! x (+ x 1))= 是原子的
16+
17+
P1 的 =(* x x)= 是原子的, 但是 =(set! x )= 不是原子的
18+
19+
- 121: P2将值设置成11 -> P1 计算 11 * 11 -> 121
20+
- 110: P1 先计算 10 * 10 = 100 -> p2 运行, x+1 = 11 -> p1 将值设计到 100
21+

0 commit comments

Comments
 (0)