SICP Exercise 3.38
来源:互联网 发布:精华液 推荐 知乎 编辑:程序博客网 时间:2024/04/30 09:51
SICP Exercise 3.38
a) I list all the orders of the three process, and then determine the value of balance. For simplicity, I use 1, 2, 3 , instead of Peter, Paul, Mary.
123
$45
132
$35
213
$45
231
$50
312
$40
321
$40
b) If the system allows the processes to be interleaved, there are some other values that could be produced, eg. $30, $55, $60, $80, $90, $110. Here I want to show you how to get these values systematicly, I won't draw the digrams.(please refer to http://wqzhang.wordpress.com/2009/07/30/sicp-exercise-3-38/ for digrams).
We need pay attention to the time of access balance and the time of set balance. I will use the following shortcut notations:
Note: the following precedure assume that, there has interleaved parts between the three processess.
- a1: access balance time of Peter.
- a2: access balance time of Paul.
- a3: access balance time of Mary.
- s1: set balance time of Peter.
- s2: set balance time of Paul.
- s3: set balance time of Mary.
(cond ((< (max a1 a2 a3) (min s1 s2 s3)) (cond ((= (max s1 s2 s3) s1) '$110) ((= (max s1 s2 s3) s2) '$80) ((= (max s1 s2 s3) s3) '$50))) ;;If s1 is big than some access time. ((and (> a2 s1) (> a3 s1)) (cond ((> s2 s3) '$90) ((> s3 s2) '$55))) ((and (> a2 s1) (< a3 s1)) (cond ((> s2 s3) '$90) ((> s3 s2) '$50))) ((and (< a2 s1) (> a2 s1)) (cond ((> s2 s3) '$80) ((> s3 s2) '$55))) ;;If s2 is big than some access time. ((and (> a1 s2) (> a3 s2)) (cond ((> s1 s3) '$90) ((> s3 s1) '$40))) ((and (> a1 s2) (< a3 s2)) (cond ((> s1 s3) '$90) ((> s3 s1) '$50))) ((and (< a1 s2) (> a3 s2)) (cond ((> s1 s3) '$110) ((> s3 s1) '$40))) ;;If s3 is big than some access time. ((and (> a1 s3) (> a2 s3)) (cond ((> s1 s2) '$60) ((> s2 s1) '$30))) ((and (> a1 s3) (< a2 s3)) (cond ((> s1 s2) '$60) ((> s2 s1) '$80))) ((and (< a1 s3) (> a2 s3)) (cond ((> s1 s2) '$110) ((> s2 s1) '$30))))
- SICP Exercise 3.38
- SICP exercise 1.43
- SICP Exercise 3.11
- SICP Exercise 3.15
- SICP Exercise 3.22
- SICP Exercise 3.25
- SICP Exercise 3.28
- SICP Exercise 3.29
- SICP Exercise 3.33
- SICP Exercise 3.34
- SICP Exercise 3.35
- SICP Exercise 3.37
- SICP Exercise 3.50
- SICP Exercise 3.51
- SICP Exercise 3.52
- SICP Exercise 3.53
- SICP Exercise 3.54
- SICP Exercise 3.55
- 单片机
- hdu 1003 Max Sum
- SendMessage 和 PostMessage 的区别(转)
- 二进制文件的读写
- ClientOMProxy
- SICP Exercise 3.38
- 游戏服务器 - 数据库异步操作技术 & 数据的保存机制
- Linux Env Tips
- OMAP uEnv.txt
- 笑话
- java异或交换两个整数或字符串原理
- HTTP协议
- android获取多媒体文件的缩略图
- 表变量与临时表的优缺点?