CIS343|510             Chapter 5B/6 Review w/ Answers

1. Which of these mutual exclusion implementations using messages is correct?

B

2. For the correct version of the above, which of the combinations given below is assumed?

a. blocking receive primitive blocking send primitive

b. blocking receive primitive nonblocking send primitive

c. nonblocking receive primitive blocking send primitive

d. nonblocking receive primitive nonblocking send primitive

B

3. Which of these combinations is known as a rendezvous?

A

4. Which of these solutions to bounded buffer producer/consumer using messages is correct?

A

5. Which of these are conditions for that must be satisfied in the classic readers/writers problem?

a. Only one reader at a time may read a file.

b. Only one writer at a time may write to a file.

c. Any number of writers may simultaneously write to a file.

d. Any number of readers may simultaneously write to a file.

e. If a writer is writing to a file, no reader may read it.

f. If a reader is reading a file, no writer may write to it.

B, D, E, F {Note: E = F}

With respect to the readers/writers solution of Fig. 5.28 . . .

6. What is the purpose of semphore x?

Protects access to readcount

7. What is the purpose of semphore wsem?

Protects access to the file read/written

8. Is one class of processes given priority over another class? Which one?

Yes, readers

9. What are the implications of that?

Writers can suffer starvation

With respect to the readers/writers solution of Fig. 5.29 . . .

10. What is the purpose of semphore rsem?

Inhibits all readers if there is a writer wishing access

11. What is the purpose of semphore wsem?

Controls access to the file read/written

12. What is the purpose of variable writecount?

Controls the setting of rsem

13. What is the purpose of semaphore y?

Controls updating of writecount

14. What is the purpose of semaphore x?

Controls updating of readcount

15. What is the purpose of semaphore z?

Gives writers priority over readers by preventing reader-buildup on rsem

16. Assume that the read/write file has no readers or writers. Suppose in a burst (for all practical purposes, sumultaneously) the following arrived:

R1 - W1 - R2 - W2- R3 - R4 - W3

Give the values of readcount & writecount and the contents of all the semaphore queues at the point in time that the first process accesses the file. Also, give the order of access to the file, assuming FIFO implementation of semaphore queues.

readcount = ; writecount = ; x.q = ; y.q = ; z.q = ; wsem.q = ; rsem.q =

Order: . . .

17. Which of the following do you see as advantages of the solution in Fig. 5.30 over the one in Fig. 5.29?

a. Readers in 5.30 have priority over writers, but not in 5.29

b. Writers in 5.30 have priority over readers but not in 5.29

c. 5.30 cannot have deadlock, but 5.29 can

d. The difficult code is given to the controller, not the reader & writer

e. 5.30 has lock step synchronization, but 5.29 does not

D only

Chapter 6 Review

Identify these necessary conditions for deadlock:

18. A process may hold allocated resources while awaiting assignment of others.

Hold and wait

19. A closed chain of processes exists.

Circular wait

20. Only one process may use a resource at a time.

Mutual exclusion

21. No resource may be forcefully removed from a process holding it.

No preemption

Identify the condition being prevented in these deadlock prevention strategies:

22. A process holding a resource must surrender it when denied a further request.

No preemption

23. In general, this condition cannot be disallowed.

Mutual Exclusion

24. Resource types have a linear ordering. Resource requests must be made in the specified order.

Circular wait

25. A process must make all its resource requests at one time.

Hold & wait

26. A resource requested by one process may be taken from the process holding it.

No preemption

Identify these deadlock avoidance strategies:

27. Grant a request only if the result of the grant is a safe state.

Resource allocation denial (banker’s algorithm)

28. Start a process only if the maximum claims of all current processes plus those of the new process can be met.

Process initiation denial

29. Rank these in order, from most conservative to least.

a. Deadlock detection & recovery

b. Deadlock prevention

c. Deadlock avoidance

B, C, A

Classify each of these in one of the categories listed immediately below:

DP. Deadlock prevention

DA. Deadlock avoidance

DDR. Deadlock detection & recovery

IDS. Integrated deadlock strategy

30. Do not start a process if its demands might lead to deadlock.

DA

30. Deny the hold and wait condition

DP

31. Successively preempt until deadlock no longer exists.

DDR

32. Group resources into classes,with linear ordering in each class. Within any class use the algorithm most appropriate for that class.

IDS

33. Back up each deadlocked process to some previously defined checkpoint. Restart all processes.

DDR

35. A process holding a resource must surrender it when denied a further request.

DP

36. Do not grant a resource request if it could lead to deadlock.

DA

37. Abort all deadlocked processes.

DDR

38. Processes must make all resource requests in a predefined order, regardless of the order of actual need by that process.

DP

39. Define safe state, according to the Banker’s Algorithm.

There is at least one sequence in which all processes can run to completion

that does not lead to deadlock

40. Define unsafe state, according to the Banker’s Algorithm.

One that is not safe

41. Since in a safe state, there are some sequences of execution that could lead to deadlock, why is it called safe? I.e., what keeps deadlock from occurring?

If one of those sequences were to occur, it would trigger resource denial by the OS

42. What is the most commonly adopted solution to deadlock recovery?

Abort all deadlocked processes

43. Be able to recognize safe & unsafe states.