time Slice rotation method (RR)
Algorithm description: Used in time-sharing system process scheduling. Each time the schedule is scheduled, always select the ready queue's first team process, allowing it to run a system pre-set time slice on the CPU. A process that does not finish running on a time slice, returns to the end of the thread queue, and waits for the next dispatch.
"Example" processes A, B, C, D need to run for 20ms, ten MS, MS, 5 MS, all arrived at 0 time. The order of arrival is a, B, C, D. If the time slices are 1 ms and 5ms respectively, the weighted turnaround time and the average weighted turnaround time are calculated for each process.
on the basis of mastering the concept of time slice rotation method, we can use an execution time graph to visualize the implementation of the process and help us understand the problem. Specific as follows:
Based on the execution time graph, it is possible to calculate the weighted turnaround time and the average weighted turnaround time for each process. It is important to remember that the arithmetic formula of the weighted turnaround time and the average weighted turnaround time:
With right turnaround time W, i.e.:
W = t/r
Where T is the turnaround time and R is the actual run time.
The average take-right turnaround time is:
Solution: Using time slice rotation method to dispatch, the performance index of the algorithm is as follows:
Arrival time |
Into Ride Name |
Arrival time |
Run time |
Start time |
Completion time |
Turnaround time |
With right Turnaround time |
Time Slice =1 |
A |
0 |
20 |
0 |
50 |
50 |
2.5 |
B |
0 |
10 |
1 |
34 |
34 |
3.4 |
C |
0 |
15 |
2 |
45 |
45 |
3.0 |
D |
0 |
5 |
3 |
20 |
20 |
4.0 |
Average turnaround time =37.25 average weighted turnaround time =3.225 |
Time Slice =5 |
A |
0 |
20 |
0 |
50 |
50 |
2.5 |
B |
0 |
10 |
5 |
30 |
30 |
3.0 |
C |
0 |
15 |
10 |
45 |
45 |
3.0 |
D |
0 |
5 |
15 |
20 |
20 |
4.0 |
Average turnaround time =36.25 average weighted turnaround time =3.125 |
Interested students can also be based on the time slice from the 1~10 changes, multiple calculation several times, and analyze the average turnaround time of each calculation, make an average turnaround time with time slices of the curve, to experience the impact of time slice changes on the average turnaround time, and analyze the reasons.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Time slice rotation scheduling algorithm for operating system