CS411/511. Operating Systems

Homework 2 - Solutions

Chapter 4: Review Questions 4.2, 4.6, 4.7

4.2. Describe the differences among short-term, medium-term, and long-term scheduling.

4.6. Describe the actions taken by a kernel to switch context

(a) Among threads

(b) Among processes

4.7. What are the differences between user-level threads and kernel-supported threads? Under what circumstances is one type "better" than the other?

Chapter 5

5.4. Suppose that the following processes arrive for execution at the times indicated. Each process will run the listed amount of time. In answering the questions, use nonpreemptive scheduling and base all decisions on the information you have at the time the decision must be made.

	     Process	    Arrival Time      Burst Time
		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 known as future-knowledge scheduling.
Remember that turnaround time is completion time minus arrival time, so you have to subtract the arrival times to compute the turnaround. FCFS is 11 if you forget to subtract arrival time.

5.6. What advantage is there in having different time-quantum sizes on different levels of a multilevel queueing system?

5.7. Consider the following preemptive priority-scheduling algorithm based on dynamically changing priorities. Larger priority numbers imply higher priority. When a process is waiting for the CPU (in the ready queue, but not running), its priority changes at a rate alpha; when it is running, the priority changes at a rate beta. All processes are given a priority of 0 when they enter the ready queue for the first time. The parameters alpha and beta can be set to give many different scheduling algorithms.

(a) What is the algorithm that results from beta > alpha > 0?

(b) What is the algorithm that results from alpha < beta < 0?

Other Question. Take the example that you just used for Question 5.4, and apply it to the following situations.

(a) Calculate the average turnaround time for a Round-Robin algorithm with q set at 2. Ignore the effects of context-switching time.

(b) Calculate the average turnaround time for the same algorithm and q, taking into effect the fact that each context switch costs .5 units of time.

(c) Suppose that a fourth process, P4, enters the system at time 7.6 and needs 6 units of CPU time. Also suppose that P2 and P3 are interactive, but P1 and P4 are batch.

A multilevel queue (but not a multilevel feedback queue) is in effect. The first queue is for interactive processes only, and has a q of 1. The second queue is for batch processes, which get up to 4 units each time they are in the CPU. Processes are dispatched as follows: 2 processes are dispatched from the interactive queue, followed by 1 process from the batch queue, etc.

Calculate the average turnaround time.