Tutorial Week 6
Questions
Q1: What is deadlock?
Q2: What is starvation, give an example?
Q3: Describe the four conditions required for deadlock to occur.
Q4*: Describe four ways to prevent deadlock by attacking the conditions required for deadlock.
Q5: Answer the following questions about the tables.
- Compute what each process still might request and display in the columns labeled "still needs".
- Is the system in a safe or unsafe state? Why?
- Is the system deadlocked? Why or why not?
- Which processes, if any, are or may become deadlocked?
- Assume a request from p3 arrives for (0,1,0,0)
- Can the request be safely granted immediately?
- In what state (deadlocked, safe, unsafe) would immediately granting the request leave the system?
- Which processes, if any, are or may become deadlocked if the request is granted immediately?
available | |||
r1 | r2 | r3 | r4 |
2 | 1 | 0 | 0 |
current allocation | maximum demand | still needs | ||||||||||
process | r1 | r2 | r3 | r4 | r1 | r2 | r3 | r4 | r1 | r2 | r3 | r4 |
p1 | 0 | 0 | 1 | 2 | 0 | 0 | 1 | 2 | ||||
p2 | 2 | 0 | 0 | 0 | 2 | 7 | 5 | 0 | ||||
p3 | 0 | 0 | 3 | 4 | 6 | 6 | 5 | 6 | ||||
p4 | 2 | 3 | 5 | 4 | 4 | 3 | 5 | 6 | ||||
p5 | 0 | 3 | 3 | 2 | 0 | 6 | 5 | 2 |
Q6: Most operating systems require opening a file before using it. Why do they require this? What are the consequences of designing a system that doesn't require a file to be opened before it is used?
Q7: On Unix systems, the open syscall supports a number of flags. Look at the man page for open to discover what these flags do, and then explain why they might be used:
- O_RDONLY, O_WRONLY, O_RDWR
- O_APPEND
- O_ASYNC
- O_DIRECT
- O_NOATIME