homework assignment #3 j. h. wang nov. 13, 2015. homework #3 chap.7: 7.6, 7.13 chap.8: 8.9, 8.16,...

14
Homework Assignment #3 J. H. Wang Nov. 13, 2015

Upload: rudolf-hopkins

Post on 21-Jan-2016

244 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Homework Assignment #3 J. H. Wang Nov. 13, 2015. Homework #3 Chap.7: 7.6, 7.13 Chap.8: 8.9, 8.16, 8.25* Chap.9: 9.11, 9.19, 9.26* (Optional: End-of-chapter

Homework Assignment #3

J. H. WangNov. 13, 2015

Page 2: Homework Assignment #3 J. H. Wang Nov. 13, 2015. Homework #3 Chap.7: 7.6, 7.13 Chap.8: 8.9, 8.16, 8.25* Chap.9: 9.11, 9.19, 9.26* (Optional: End-of-chapter

Homework #3

• Chap.7: 7.6, 7.13• Chap.8: 8.9, 8.16, 8.25*• Chap.9: 9.11, 9.19, 9.26*• (Optional: End-of-chapter

programming projects in Chap. 7& 9)• Due: two weeks (Nov. 27, 2015)

Page 3: Homework Assignment #3 J. H. Wang Nov. 13, 2015. Homework #3 Chap.7: 7.6, 7.13 Chap.8: 8.9, 8.16, 8.25* Chap.9: 9.11, 9.19, 9.26* (Optional: End-of-chapter

• Chap. 7:– 7.6: In a real computer system, neither the

resources available nor the demands of processes for resources are consistent over long periods (months). Resources break or are replaced, new processes come and go, new resources are bought and added to the system. If deadlock is controlled by the banker’s algorithm, which of the following changes can be made safely (without introducing the possibility of deadlock), and under what circumstances?

(to be continued…)

Page 4: Homework Assignment #3 J. H. Wang Nov. 13, 2015. Homework #3 Chap.7: 7.6, 7.13 Chap.8: 8.9, 8.16, 8.25* Chap.9: 9.11, 9.19, 9.26* (Optional: End-of-chapter

(… continued from the previous slide)

(a) Increase Available (new resources added)(b) Decrease Available (resource permanently removed from system)(c) Increase Max for one process (the process needs more resources than allowed, it may want more)(d) Decrease Max for one process (the process decides it does not need that many resources)(e) Increase the number of processes(f) Decrease the number of processes

Page 5: Homework Assignment #3 J. H. Wang Nov. 13, 2015. Homework #3 Chap.7: 7.6, 7.13 Chap.8: 8.9, 8.16, 8.25* Chap.9: 9.11, 9.19, 9.26* (Optional: End-of-chapter

– 7.13: Consider the following snapshot of a system :

(to be continued…) AllocationA B C D

MaxA B C D

AvailableA B C D

P0 2 0 0 1 4 2 1 2 3 3 2 1

P1 3 1 2 1 5 2 5 2

P2 2 1 0 3 2 3 1 6

P3 1 3 1 2 1 4 2 4

P4 1 4 3 2 3 6 6 5

Page 6: Homework Assignment #3 J. H. Wang Nov. 13, 2015. Homework #3 Chap.7: 7.6, 7.13 Chap.8: 8.9, 8.16, 8.25* Chap.9: 9.11, 9.19, 9.26* (Optional: End-of-chapter

(… continued from the previous slide)

Answer the following questions using the banker’s algorithm:(a) Illustrate that the system is in a safe state by demonstrating an order in which the processes may complete.(b) If a request from process P1 arrives for (1,1,0,0), can the request be granted immediately? Why?(c) If a request from process P4 arrives for (0,0,2,0), can the request be granted immediately? Why?

Page 7: Homework Assignment #3 J. H. Wang Nov. 13, 2015. Homework #3 Chap.7: 7.6, 7.13 Chap.8: 8.9, 8.16, 8.25* Chap.9: 9.11, 9.19, 9.26* (Optional: End-of-chapter

• Chap. 8:– 8.9: Compare paging with segmentation

with respect to how much memory the address translation structures require to convert virtual addresses to physical addresses.

Page 8: Homework Assignment #3 J. H. Wang Nov. 13, 2015. Homework #3 Chap.7: 7.6, 7.13 Chap.8: 8.9, 8.16, 8.25* Chap.9: 9.11, 9.19, 9.26* (Optional: End-of-chapter

– 8.16: Consider a computer system with a 32-bit logical address and 4-KB page size. The system supports up to 512MB of physical memory. How many entries are there in each of the following?(a) A conventional single-level page table(b) An inverted page table

Page 9: Homework Assignment #3 J. H. Wang Nov. 13, 2015. Homework #3 Chap.7: 7.6, 7.13 Chap.8: 8.9, 8.16, 8.25* Chap.9: 9.11, 9.19, 9.26* (Optional: End-of-chapter

– 8.25*: Assume that a system has a 32-bit virtual address with a 4-KB page size. Write a C program that is passed a virtual address (in decimal) on the command line and have it output the page number and offset for the given address.

(to be continued…)

Page 10: Homework Assignment #3 J. H. Wang Nov. 13, 2015. Homework #3 Chap.7: 7.6, 7.13 Chap.8: 8.9, 8.16, 8.25* Chap.9: 9.11, 9.19, 9.26* (Optional: End-of-chapter

– (… continued from the previous slide)

As an example, your program would run as follows:

./a.out 19986

Your program would output:

The address 19986 contains:page number=4offset=3602

Writing this program will require using the appropriate data type to store 32 bits. We encourage you to use unsigned data types as well.

Page 11: Homework Assignment #3 J. H. Wang Nov. 13, 2015. Homework #3 Chap.7: 7.6, 7.13 Chap.8: 8.9, 8.16, 8.25* Chap.9: 9.11, 9.19, 9.26* (Optional: End-of-chapter

• Chap. 9:– 9.11: Discuss situations in which the least

frequently used (LFU) page-replacement algorithm generates fewer page faults than the least recently used (LRU) page-replacement algorithm. Also discuss under what circumstances the opposite holds.

– 9.19: What is the cause of thrashing? How does the system detect thrashing? Once it detects thrashing, what can the system do to eliminate this problem?

Page 12: Homework Assignment #3 J. H. Wang Nov. 13, 2015. Homework #3 Chap.7: 7.6, 7.13 Chap.8: 8.9, 8.16, 8.25* Chap.9: 9.11, 9.19, 9.26* (Optional: End-of-chapter

– 9.26*: Write a program that implements the FIFO, LRU, and optimal page-replacement algorithms presented in this chapter. First, generate a random page-reference string where page numbers range from 0 to 9. Apply the random page-reference string to each algorithm, and record the number of page faults incurred by each algorithm. Implement the replacement algorithm so that the number of page frames can vary from 1 to 7. Assume that demand paging is used.

Page 13: Homework Assignment #3 J. H. Wang Nov. 13, 2015. Homework #3 Chap.7: 7.6, 7.13 Chap.8: 8.9, 8.16, 8.25* Chap.9: 9.11, 9.19, 9.26* (Optional: End-of-chapter

End-of-chapter programming projects

• Ch.7*: Banker’s Algorithm– Write a multithreaded program that implements the

banker’s algorithm discussed in Section 7.5.3.

• Ch.9*: Designing a Virtual Memory Manager– This project consists of writing a program that translates

logical to physical addresses for a virtual address space of size 216=65,536 bytes.

Page 14: Homework Assignment #3 J. H. Wang Nov. 13, 2015. Homework #3 Chap.7: 7.6, 7.13 Chap.8: 8.9, 8.16, 8.25* Chap.9: 9.11, 9.19, 9.26* (Optional: End-of-chapter

Any Questions or Comments?