5.4
5.4 Consider the following set of processes, with the length of the CPU burst time 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)?
大致翻译:这里有五个进程以P1,P2,P3,P4,P5的顺序同时在0时刻到达,画出FCFS,SJF,非抢占式优先级和RR(时间片长度为2)的甘特图,写出上述四种算法得轮转时间、等待时间和最小平均等待时间。
知识点:对调度算法的理解,甘特图的绘制。
(1)FCFS: 先到先服务(非抢占)
直接按到达顺序先到先服务啦~
(2)SJF:最短作业优先调度(优先级调度的特例)(可抢占可非抢占)
执行时间短的先啦~
当到达时间不同时, 将 新来的执行时间 与 之前的剩余的执行时间 对比,短的优先~(就可能存在抢占啦)
(3)非抢占优先级:
就是多加了个优先级,优先级大的优先,执行时间少的优先~(注意看数字大的代表优先级大还是数字小代表优先级大)
(4)RR:非抢占轮转调度
固定时间片!!!!也就是固定一个程序最多一次只能运行一个时间片的时间(如 时间片=2)
然后注意到达时间,不看优先级,按顺序噢~
(5)抢占轮转调度(第二题用)
考虑优先级、时间片、到达先后 ,时间相同的话按先到先服务
(1)周转时间:从到达时间 到 执行完 所用的时间~
(2)等待时间:到达以后 等待的所有小时间相加
(3)平均等待时间:每个任务等待时间相加,除以总任务数
(4)CPU运行效率:非空转时间占总时间的比例
5.5
The following processes are being scheduled using a preemptive, roundrobin scheduling algorithm.
Each process is assigned a numerical priority,with a higher number indicating a higher relative priority. In addition to the processes listed below, the system also has an idle task (which consumes no CPU resources and is identified as [公式] ). This task has priority 0 and is scheduled whenever the system has no other available processes to run. The length of a time quantum is 10 units. If a process is preempted by a higher-priority process, the preempted process is placed at the end of the queue.
a. Show the scheduling order of the processes using a Gantt chart.
b. What is the turnaround time for each process?
c. What is the waiting time for each process?
d. What is the CPU utilization rate?
大致翻译:这些进程将会被抢占式的轮转调度算法所调度,每一个进程都拥有一个数字表示的优先级,数字大代表着高优先级,除了上述所说的进程,系统在空转的时候会执行Pidle 进程(不消耗任何CPU资源),时间片的大小为10个时间单元,如果一个进程被高优先级的进程抢占,被抢占的进程将会放在队列的末尾。
使用甘特图画出这些进程的调度情况,计算出每个进程的轮转时间、等待时间和CPU的使用率。
知识点:抢占式RR算法
一个program~
看下面连接叭:https://zhuanlan.zhihu.com/p/83470448