{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# 7-sol - CHAPTER 7 Deadlocks Practice Exercises 7.1 List...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
22 Chapter 7 Deadlocks for(inti=0;i<n; i++) { // first find a thread that can finish for(intj=0;j<n; j++) { if (!finish[j]) { boolean temp = true; for(intk=0;k<m; k++) { if (need[j][k] > work[k]) temp = false; } if (temp) { // if this thread can finish finish[j] = true; for(intx=0;x<m; x++) work[x] += work[j][x]; } } } } Figure 7.1 Banker’s algorithm safety algorithm. Currently there are two resources available. This system is in an un- safe state as process P 1 could complete, thereby freeing a total of four resources. But we cannot guarantee that processes P 0 and P 2 can com- plete. However, it is possible that a process may release resources before requesting any further. For example, process P 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 4

7-sol - CHAPTER 7 Deadlocks Practice Exercises 7.1 List...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online