Scheduling ========== 1) Make assumptions & Set parameters. a) Are the job duration times known or unknown? b) What is the distribution of job duration times? c) What is the distribution of job arrival times? d) Can jobs be preempted (interrupted)? e) Are some jobs more important than others (priority)? f) How many resources are there to schedule? g) Do the jobs need more than one kind of resource (e.g., CPU bound vs. I/O bound processes)? 2) Choose metrics (some are to be minimized, some are to be maximized). a) turnaround time (and average turnaround time) b) response time (and average response time) c) waiting time (and average waiting time) d) total completion time e) CPU utilization f) CPU throughput g) "fairness" (no "starvation") 3) Choose an algorithm. a) FCFS b) SJF c) LJF d) RR (round robin) e) STCF (shortest time to complete first) f) Priority g) MLFQ (Multilevel Feedback Queue) 4) Analyze. How well does the chosen algorithm optimize the chosen metrics given the assumptions and parameters? Here are definitions for the above metrics. Turnaround time (for a process): The amount of time between when a process first arrives in the ready state and when it exits the running state for the last time. Response time (for a process): The amount of time between when a process first arrives in the ready state and when it enters the running state for the first time. Waiting time (for a process): The sum of the time spent in the ready queue during the life of the process. Time blocked, waiting for I/O, is not part of the waiting time. Total Completion Time (of all processes): The amount of time between the start of the first process and the completion of the last process (this assumes that we are running a finite set of processes). NOTE: If there is only one CPU, then total completion time does not depend on the choice of scheduling algorithm. CPU Utilization: The percentage of time that the CPU is busy (not idle). CPU Throughput: The number of processes that are completed per time unit. Here are the assumptions that we start with for FCFS and SJF (all of these assumptions will eventually be changed or eliminated). (1) There is only one CPU. (2) All the jobs arrive at the same time. (3) Once a job is started, it runs to completion (no preemption). (4) Jobs don't need any other resources (no I/O operations). (5) We know ahead of time each job's run-time (its duration). Note: To do STCF, we need to eliminate assumptions (2) and (3). To do Round-robin (RR), we need to eliminate assumption (3). To do MLFQ we need to eliminate assumption (4). To affect total completion time we need to eliminate assumption (1). When thinking about CPU scheduling algorithms, it often helps to keep in mind several other common scheduling situations. a) grocery store checkout lines b) elevators c) disk drive heads d) deliveries