Professional Documents
Culture Documents
Cpu Scheduling Assignment
Cpu Scheduling Assignment
2. Suppose that the following processes arrive for execution at the times indicated. Each
process will run for the amount of time listed. In answering the questions, use
nonpreemptive scheduling, and base all decisions on the information you have at the time
the decision must be made.
a. What is the average turnaround time for these processes with theFCFS 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.
4. Why is it important for the scheduler to distinguish I/O-bound programs from CPU-
bound programs?
5. Suppose that a scheduling algorithm (at the level of short-term CPU scheduling) favors
those processes that have used the least processor time in the recent past. Why will this
algorithm favor I/O-bound programs and yet not permanently starve CPU-bound
programs?
1
6. Discuss how the following pairs of scheduling criteria conflict in certain settings.
a. CPU utilization and response time
b. Average turnaround time and maximum waiting time
c. I/O device utilization and CPU utilization
7. 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.
a. Draw four Gantt charts that illustrate the execution of these processes using the
following scheduling algorithms: FCFS, SJF, nonpreemptive priority (a larger priority
number implies a higher priority), and RR (quantum = 2).
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 these scheduling algorithms?
d. Which of the algorithms results in the minimum average waiting time (over all
processes)?
8. Explain the differences in how much the following scheduling algorithms discriminate in
favor of short processes:
a. FCFS
b. RR
10. Five batch jobs, A through E, arrive at a computer center at almost the same time. They
have estimated running times of 10, 6, 2, 4, and 8 minutes. Their (externally determined)
priorities are 3, 5, 2, 1, and 4, respectively, with 5 being the highest priority. For each of
the following scheduling algorithms, determine the average turnaround time. Ignore
process switching overhead.
a. Round robin (Time Quantum = 3 minutes).
b. Priority scheduling.
c. First-come, first-served (run in order 10, 6, 2, 4, 8).
d. Shortest job first.
2
For (a), assume that the system is multiprogrammed, and that each job gets its fair share
of the CPU. For (b) through (d), assume that only one job at a time runs, until it finishes.
All jobs are completely CPU bound.
a. Draw three Gantt charts that illustrate the execution of these processes using the
following scheduling algorithms: shortest remaining time, nonpreemptive priority (a
smaller priority number implies higher priority) and round robin with quantum 30 ms.
b. What is the average waiting time of the above scheduling policies?