现代操作系统第四版第六章部分习题(英文)

绝大部分是上课期间的作业,可能后续会有补充,也可能没有
部分内容有参考(包括博客,随书的参考资料,课程资料等等),部分内容是自己写的

另,因为课程要求,所以作为作业上交的部分是用英文完成的,后续补充用英文还是中文看心情叭hhh
操作系统的初学者,如有疏漏或错误,欢迎指正 (^ _ ^)

22.A system has two processes and three identical resources. Each process needs a maximum of two resources. Is deadlock possible? Explain your answer.
The system is deadlock free. Suppose that each process has one resource. There is one resource free. Either process can ask for it and get it, in which case it can finish and release both resources. Consequently, deadlock is impossible.

26.A system has four processes and five allocatable resources. The current allocation and maximum needs are as follows:现代操作系统第四版第六章部分习题(英文)What is the smallest value of x for which this is a safe state?
这道题如果按照原题来计算的话存在一点问题,因此将Process A的Maximum改为1 1 2 1 2,相应的答案也会有一定的变化
he needs matric is as follows:
0 1 0 0 1
0 2 1 0 0
1 0 3 0 0
0 0 1 1 1
If x is 0, we have a deadlock immediately.
If x is 1, process D can run to completion. When it is finished, the available
vector is 1 1 2 2 1 and A can run. After it finishes and returns its resources
the available vector is 2 1 4 3 2, which will allow C to run and complete, and then B to run and complete. Therefore, the smallest value of x that avoids a
deadlock is 1
下面是常使用的一种解题的表达方式:

Work Need Allocation Work+Allocation Finish
D 0 0 1 1 1 0 0 1 1 1 1 1 1 1 0 1 1 2 2 1 true
A 1 1 2 2 1 0 1 0 0 1 1 0 2 1 1 2 1 4 3 2 true
C 2 1 4 3 2 1 0 3 0 0 1 1 0 1 0 3 2 4 4 2 true
B 3 2 4 4 2 0 2 1 0 0 2 0 1 1 0 5 2 5 5 2 true

29.A distributed system using mailboxes has two IPC primitives, send and receive. The latter primitive specifies a process to receive from and blocks if no message from that process is available, even though messages may be waiting from other processes. There are no shared resources, but processes need to communicate frequently about other matters. Is deadlock possible? Discuss.
Yes. Suppose that all the mailboxes are empty. Now A sends to B and waits for a reply, B sends to C and wait for a reply, and C sends to A and waits for a reply. All the conditions for a communications deadlock are now fulfilled.