简体   繁体   中英

FCFS versus SJF versus RR

In C, supposing that each algorithm was given the exact same set of processes, would the turnaround time be equal between first come first serve, shortest job first, and round robin? Or would it differ between scheduling algorithms?

SJF has the best average turnaround time, followed by FCFS. RR has the worst turnaround time, in comparison.

Explanation:

FCFS scheduling is the simplest scheduling algorithm, but it can cause short processes to wait for very long processes (convoy effect).

SJF scheduling is an improvement over FCFS, taking into account the length of time a process needs to complete (CPU burst). SJF is provably optimal, providing the shortest average waiting time. Implementing SJF scheduling is difficult, however, because predicting the length of the next CPU burst is difficult. Furthermore, processes that have long running times may starve under SJF, if there are too many short ones.

RR offers a solution to the fairness issue, providing better average response time. That typically comes at the cost of a higher average turnaround time though.

At the end of the day, it is a tradeoff between average turnaround time and fairness in terms of response time.

Here is another link to help you out: https://homes.cs.washington.edu/~arvind/cs422/lectureNotes/sched-6.pdf

Alternatively, you could check out Chapter 6 CPU Scheduling of the following book:

Operating System Concepts, 9th Edition by Silberschatz, Galvin, and Gagne

Generally, First Come First Serve (FCFS) and Shortest Job First (SJF) are implemented to favor turnaround time while Round Robin (RR) is implemented to favor the response time. It is usually a trade off. This means given the same processes (also depending on the type of workload), SJF and FCFS would generally have better turnaround time than RR and vice versa, RR would generally have a better response time than both.

To understand this better, you can read http://pages.cs.wisc.edu/~remzi/OSTEP/cpu-sched.pdf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM