(Job, process) scheduling algorithm

Source: Internet
Author: User

(1) First come first service scheduling algorithm (FCFS) (Job, process scheduling): The algorithm is simple, but the efficiency is low, is advantageous for the long job, but is unfavorable to the short work, is advantageous to the CPU busy job, is unfavorable to the I/O busy job.
(2) Short job priority scheduling algorithm (SJF) (Job, process scheduling): A process with short running time (job) takes precedence, the algorithm is bad for long job, it is easy to cause "hunger" problem, that is, long process (job) due to low priority may not be processed for a long time.
(3) Time slice rotation scheduling algorithm (process scheduling):
The size of the time slice has a large impact on the system performance, if the time slice is large enough that all processes can be executed in a time slice, then the FCFS algorithm, if the time slice is very small, then the processor is switching between processes frequently, the processor real time to run the user process will be reduced.
The length of time slices is determined by the response time of the system, the number of processes in the ready queue and the processing capacity of the system.
(4) Priority scheduling algorithm (job, process scheduling): Processes that run based on process priorities
(5) High response ratio priority scheduling algorithm (Job scheduling): Response ratio = 1 + Job wait time/estimated run time focus content
(6) Multi-level queue scheduling algorithm (process scheduling): Design different scheduling algorithms for multiple ready queues
(7) Multilevel feedback queue scheduling algorithm: (Unix dispatch with this)
The FCFS scheduling algorithm and priority scheduling algorithm are synthesized.
Realization idea:
1) Set up multiple ready queues in the system, one priority for each ready queue, the highest priority for the first queue, and the second, followed by lower priority for the remaining queues.
2) Each queue has different time slices for the execution of the process, and the higher the priority of the queue, the shorter the corresponding time slice, that is, the shorter the time slice in the higher priority queue.
3) When a new process is in the system, first put it to the end of the first queue, the principle of installing FCFS queue waiting for scheduling. When the turn of the process is executed, if it can be completed in this time, you can prepare the evacuation system, if it is not completed at the end of a time slice, the scheduler will transfer the process to the 2nd queue, and then also the principle of fcfs wait for scheduling; if it runs a time slice in the 2nd queue, it is still incomplete. into a third queue. In this way, the time slice rotation scheduling algorithm is used in the last queue.
4) The scheduler selects the process from the second queue only if the first queue is empty, and the scheduler selects the process from the I queue only if the 1th queue to I-1 is empty. When the processor is performing a process in the queue I, if a new process enters a higher priority queue, then the new process will preempt the processor that is running the process, that is, the scheduler puts the executing process back into the I queue and re-assigns the processor to a new higher-priority process.

Job turnaround time (Ti) = wait time for job I + run time for job I (completion of job I-time of job I)
Average turnaround time (T) = (T1 + T2 + ...) + Tn)/n
Take ownership turnaround time (Wi) = run time of job I/job I.
Average weighted turnaround time (W) = (W1 + W2 + ... + Wn)/n

Examples:
For example, the arrival time and run time as shown in the figure:

Job Number Arrival Time Run Time priority (smaller, more preferred)
A 0 2 4
B 1 5 9
C 2 8 1
D 3 3 8

First Come first service:

Job Number Arrival Time Run Time Wait Time Start Time End Time Turnaround Time turnaround time with weight
A 0 2 0 0 2 2 2/2=1
B 1 5 1 2 7 6 6/5=1.2
C 2 8 5 7 15 13 13/8=1.625
D 3 3 12 15 18 15 15/3=5
Average 9 2.2

Short Job Priority:

Job Number Arrival Time Run Time Wait Time Start Time End Time Turnaround Time turnaround time with weight
A 0 2 0 0 2 2 2/2=1
B 1 5 1 2 7 6 6/5=1.2
D 3 3 4 7 10 7 7/3=2.33
C 2 8 8 10 18 16 16/8=2
Average 7.75 1.63

Static priority:

Job Number Arrival Time Run Time Wait Time Start Time End Time Turnaround Time turnaround time with weight
A 0 2 0 0 2 2 2/2=1
C 2 8 0 2 10 8 8/8=1
D 3 3 7 10 13 10 10/3=3.33
B 1 5 12 13 18 17 17/5=3.4
Average 9.25 2.18

Example two:
4 processes A, B, C, D, simultaneous arrival, running time of 6, 3, 1, 7 (MS), using time-slice rotation scheduling algorithm (time slices are 1 and 3, not preemption)

Time Slice is 1
Scheduling diagram:

One A - - the - -
1 2 3 4 5 6 7 8 9 Ten
A B C D A B D A B D A D A D A D D

Average Wait Time: ((0+3+2+2+1+1) + (1+3+2) +2+ (3+2+2+1+1+1+0))/4 = 6.75
Average turnaround time = average Wait time + average run time = 6.75 + (6+3+1+7)/4 = 11

The time slice is 3:
Scheduling diagram:

One A - - the - -
1 2 3 4 5 6 7 8 9 Ten
A A A B B B C D D D A A A D D D D

Average Wait Time: ((0+7) +3+6+ (7+3))/4 = 6.5
Average turnaround time = average Wait time + average run time = 6.5 + (6+3+1+7)/4 = 10.75

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.