Download presentation
Published byClifford Short Modified over 9 years ago
1
Homework Assignment #2 J. H. Wang Oct. 17, 2007
2
Homework #2 Chap.5: 5.2, 5.4 Chap.6: 6.3, 6.8* Chap.7: 7.8, 7.10
(Optional: End-of-chapter project for Chaps. 6) Due: two to three weeks (Oct. 31, 2007-Nov. 7, 2007)
3
Chap.5 5.2: Consider the following set of processes, with the length of the CPU burst given in milliseconds: The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0. (See more on the next page) Process Burst Time Priority P1 10 3 P2 1 P3 2 P4 4 P5 5
4
(a) Draw four Gantt charts that illustrate the execution of these processes using the following scheduling algorithms: FCFS, SJF, nonpreemptive priority (a smaller priority number implies a higher priority), and RR (quantum =1). (b) What is the turnaround time of each process for each of the scheduling algorithms in part (a)? (c) What is the waiting time of each process for each of the scheduling algorithms in part (a)? (d) Which of the algorithms in part (a) results in the minimum average waiting time (over all processes)?
5
5.4: Which of the following scheduling algorithms could result in starvation? (a) First-come, first-served (b) Shortest job first (c) Round robin (d) Priority
6
Chap.6 6.3: Explain why implementing synchronization primitives by disabling interrupts is not appropriate in a single-processor system if the synchronization primitives are to be used in user-level programs.
7
6. 8: The Sleeping-Barber Problem
6.8: The Sleeping-Barber Problem. A barbershop consists of a waiting room with n chairs and a barber room with one barber chair. If there are no customers to be served, the barber goes to sleep. If a customer enters the barbershop and all chairs are occupied, then the customer leaves the shop. If the barber is busy but chairs are available, then the customer sits in one of the free chairs. If the barber is asleep, the customer wakes up the barber. Write a program to coordinate the barber and the customers.
8
Chap.7 7.8: Consider the following snapshot of a system:
Allocation A B C D Max A B C D Available A B C D P0 P1 P2 P3 P4
9
Answer the following questions using the banker’s algorithm:
(a) What is the content of the matrix Need? (b) Is the system in a safe state? (c) If a request from process P1 arrives for (0,4,2,0), can the request be granted immediately?
10
7.10: A single-lane bridge connects the two Vermont villages of North Tunbridge and South Tunbridge. Farmers in the two villages use this bridge to deliver their produce to the neighboring town. The bridge can become deadlcoked if both a northbound and a southbound farmer get on the bridge at the same time (Vermont farmers are stubborn and are unable to back up.) Using semaphores, design an algorithm that prevents deadlock. Initially, do not be concerned about starvation (the situation in which northbound farmers prevent southbound farmers from using the bridge, and vice versa).
11
Optional End-of-Chapter Project
Project for Chap. 6: Producer-Consumer Problem Pthreads mutex locks/semaphores Win32 mutex locks/semaphores
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.