Chapter 6 Operating Systems
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.
((P1's waiting time + P1's brust time) + (P2's waiting time + P2's brust time) + (P3's waiting time + P3's brust time)) / 3 a. ((0 + 8) + (7.6 + 4) + (11+ 1) ) / 3 = 10.5333 b. ((0 + 8) + (8.6 + 4) + (7+ 1) ) / 3 = 9.5333 c. ((6 + 8) + (1.6 + 4) + (0+ 1) ) / 3 = 6.866 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
Define the difference between preemptive and nonpreemptive schduling. State why strict nonpreemptive scheduling is unlikely to be used in a computer center.
(1) Preemptive scheduling allows a process to be interrupted in the midst of its execution, taking the CPU away and allocating it to another process. Nonpreemptive scheduling ensures that a process relinquishes control of the CPU only when it finishes with its current CPU burst. (2) If nonpreemptive scheduling is used in a computer center, a process is capable of keeping other processes waiting for a long time.
Consider a variant of the RR scheduling algorithm where the entries in the ready queue are pointers to the PCBs. A. What would be the effect of putting two pointers to the same process in the ready queue? B. What would be the major advantages and disadvantages of this scheme? C. How would you modify the basic RR algorithm to achieve the same effect without the duplicate pointers?
A.Priority process will get more precedence because two pointers can access priority process more often. B.Higher priority process will get more time to process. Otherwise, lower priority process will get less time to process. C.Spend more time on higher priority process.
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?
It will favour the I/O-bound programs because of the relatively short CPU burst request by them; however, the CPU-bound programs will not starve because the I/O-bound programs will relinquish the CPU relatively often to do their I/O.
What advantage is there in having different time-quantum sizes on different levels of a multilevel queueing system?
Processes which need more frequent servicing, such as interactive processes, can be in a queue with a small q. Processes that are computationally intensive can be in a queue with a larger quantum, requiring fewer context switches to complete the processing, making more efficient use of the CPU.
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 α; when it is running, its priority changes at a rate β. All processes are given a priority of 0 when they enter the ready queue. The parameters α and β can be set to give many different scheduling algorithms. A. What is the algorithm that results from β > α > 0? B. What is the algorithm that results from α < β < 0?
Solution (a) What is the algorithm that results from β > α > 0? Since β is a rate and it is greater than that of α, processes that are running will con- tinually receive a much higher priority. At the same time, the priority of processes waiting to be run will increase, however, this increase will not be as fast as the pro- cess running on the CPU. This will result in a first-come first-serve (FCFS) type of situation where when no process is running the one that has been waiting the longest will be ran, and its priority will continuously increase faster than the others until it stops. Solution (b) What is the algorithm that results from α < β < 0? New processes in this scheme will always be ran immediately, and older processes will sit in the ready queue until the most recent process finishes. This is essentially Last In First Out.
Explain the differences in the degree to which the following scheduling algorithms discriminate in favor of short processes: A. FCFS B. RR C. Multilevel feedback queues
a. FCFS—discriminates against short jobs since any short jobs arriving after long jobs will have a longer waiting time. b. RR—treats all jobs equally (giving them equal bursts of CPU time) so short jobs will be able to leave the system faster since they will finish first. c. Multilevel feedback queues—work similar to the RR algorithm— they discriminate favorably toward short jobs.
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 scheduling algorithms 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 sets of algorithms? A. Priority and SJF B. Multilevel feedback queues and FCFS C. Priority and FCFS D. RR and SJF
a. The shortest job has the highest priority. b. The lowest level of MLFQ is FCFS. c. FCFS gives the highest priority to the job having been in existence the longest. d. None.
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 schedules in part A results in the minimal average waiting time (over all processes)?
b & c see images d. SJF (either nonpreemptive algorithm or preemptive algorithm, since they given the same result in this case) has the minimum average waiting time.
A CPU scheduling algorithm determines an order for the execution of its scheduled processes. Given n processes to be scheduled on one processor, how many possible different schedules are there? Give a formula in terms of n.
n! (n factorial = n × (n - 1) × ( n - 2) × ... × 2 × 1).