Homework#1 2
Homework#1 2
Page
College of Computer Science and Engineering
Department of Computer Science
P1 0.0 8
P2 0.4 4
P3 1.0 1
a. What is the average turnaround time for these processes with the FCFS scheduling algorithm؟
b. What is the average turnaround time for these processes with the SJF scheduling algorithm؟
c. The SJF algorithm is supposed to improve performance, but notice that we chose to run process P1 at time 0
because we did not know that two shorter processes would arrive soon. Compute what the average turnaround time
will be if the CPU is left idle for the first 1 unit and then SJF scheduling is used. Remember that processes P1 and P2
are waiting during this idle time, so their waiting time may increase. This algorithm could be called future-knowledge
scheduling.
2-2- What advantage is there in having different time-quantum sizes at different levels of a multilevel queueing
system؟
2-3- Many CPU-scheduling algorithms are parameterized. For example, the RR algorithm requires a parameter to
indicate the time slice. Multilevel feedback queues require parameters to define the number of queues, the
1
scheduling algorithm for each queue, the criteria used to move processes between queues, and so on. These
algorithms are thus really sets of algorithms (for example, the set of RR algorithms for all time slices, and so on). One
set of algorithms may include another (for example, the FCFS algorithm is the RR algorithm with an infinite time
quantum). What (if any) relation holds between the following pairs of algorithm sets؟
d. RR and SJF
2- Deadlocks
2-1- Consider the following snapshot of a system:
P1 1000 1750
P2 1354 2356
P3 0632 0652
P4 0014 0656
c. If a request from process P1 arrives for (0,4,2,0), can the request be granted immediately?
Allocation Max
ABCD ABCD
P0 3014 5117
P1 2210 3211
P2 3121 3321
P3 0510 4612
P4 4212 6325
Using the banker’s algorithm, determine whether or not each of the following states is unsafe. If the state is safe,
illustrate the order in which the processes may complete. Otherwise, illustrate why the state is unsafe.
a. Available(1 ،0 ،3 ،0) =
b. Available = (1, 0, 0, 2)
2
2-3- Consider the following snapshot of a system:
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؟
c. If a request from process P4 arrives for (0, 0, 2, 0), can the request be granted immediately?
3- Virtual Memory
3-1- Consider the following page reference string:
1.6 ،3 ،2 ،1 ،2 ،3 ،6 ،7 ،3 ،2 ،1 ،2 ،6 ،5 ،1 ،2 ،4 ،3 ،2 ،
How many page faults would occur for the following replacement algorithms, assuming one, two, three, four, five,
six, and seven frames ؟Remember that all frames are initially empty, so your first unique pages will cost one fault
each.
•LRU replacement
•FIFO replacement
• Optimal replacement
4- Mass-Storage Structure
4-1- Suppose that a disk drive has 5,000 cylinders, numbered 0 to 4,999. The drive is currently serving a request at
cylinder 2,150, and the previous request was at cylinder 1,805. The queue of pending requests, in FIFO order, is:
2,069, 1,212, 2,296, 2,800, 544, 1,618, 356, 1,523, 4,965, 3681
Starting from the current head position, what is the total distance (in cylinders) that the disk arm moves to satisfy all
the pending requests for each of the following disk-scheduling algorithms؟
a. FCFS
b. SSTF
c. SCAN
d. LOOK
e. C-SCAN
f. C-LOOK