Job scheduling algorithm

Source: Internet
Author: User

In a multi-channel program environment, there are many processes in main memory, often more than the number of processors. This requires the system to dynamically assign the processor to a process in the ready queue according to an algorithm, and the task of the assignment processor is done by the processor scheduler.

Processor Scheduling

In the multi-channel program system, after a job is submitted, it must be dispatched by the processing machine before it can get the processor execution. For batch jobs , it is often necessary to experience job scheduling (also known as advanced scheduling ) and process scheduling (also known as low-level scheduling ) for two processes to obtain a processor; In the case of terminal-type jobs , the processor is usually available only through process scheduling . In addition to the above two scheduling, the operating system is often also set up intermediate scheduling, used to improve memory utilization.

  job: is a broader concept than the program, it contains not only the usual procedures and data, but also with a job description, the system is based on the instructions to control the operation of the program. Some of the above-mentioned algorithms are some of the common scheduling algorithms that we will refer to later.

  Advanced scheduling (Job scheduling): Its main function is based on an algorithm, the external memory on the backup queue of those jobs into memory, that is, the scheduled object is the job.

  Low-level scheduling (process scheduling): used to determine which process in the ready queue should get the processor, and then the dispatcher performs the specific operation of assigning the handler to the process.

  Intermediate Scheduling : The main purpose is to improve memory utilization and system throughput. It works by moving a process that is temporarily not running to external memory, where the state is called a hang. Instead, when memory is idle, they are recalled back to memory, where the state is called ready and hangs on the ready queue waiting for the schedule of the process.

In order to evaluate the merits and demerits of the algorithm, different performance analysis criteria are proposed:

1. CPU Utilization:

CPU is the most important expensive resource in computer system, so the CPU should be kept in working state as much as possible.

2. System throughput:

The number of CPUs completed in a unit of time, long operations need to consume a longer processor time, so it will reduce the system's throughput;

3. Turnaround time:

The amount of time that has elapsed since the job was submitted to the completion of the job, including job waits, queues in the ready queue, running on the processing machine, and the sum of time spent in the input and output operations.

Turnaround time = Job completion time-job submission time

Average Turnaround time = (Job 1 turnaround time + Job 2 turnaround time +...+ job n turnaround time)/n

Take Ownership turnaround time = turnaround time/job actual run time

Average take right turnaround time = (+...+ of Job 1 with right turnaround time of job N)/n

4. Wait Time:

Refers to the process is in the same processor state of the sum of time, the longer the waiting time, the lower the user satisfaction. The processor scheduling algorithm does not actually affect the time of job execution or input/output operations, it only affects the time it takes for the job to wait in the ready queue. Therefore, to measure a scheduling algorithm is often just a matter of simply examining the waiting time.

5. Response Time:

Refers to the time taken from a user submitting a request to the system first generating a response. In the interactive system, turnaround time cannot be the best evaluation criterion, and the response time is generally used as one of the important criteria to measure the scheduling algorithm. From the user's point of view, the scheduling strategy should try to reduce the response time, so that the response time is within the user's acceptable range.

Several common scheduling algorithms:

1. First come first service scheduling algorithm (FCFS)

  Schedule jobs According to the natural order in which each job enters the system. The advantage of this scheduling algorithm is to achieve simple, fair. The disadvantage is that it does not take into account the comprehensive use of various resources in the system, often makes the short job users dissatisfied, because the short job waiting for processing time may be much longer than the actual running time.

Advantages: fairness, simple implementation;

Disadvantage: not conducive to short work.

Average wait time t = (0+1.6+2.2+2.5)/4=1.575
Average turnaround time T = (2+2.6+2.7+2.7)/4=2.5
Average weighted turnaround time W = (1+2.6+5.4+13.5)/4=5.625

2. Short job (process) Priority scheduling algorithm

  The scheduling algorithm for short job first (SJF) is to select one or several jobs with the shortest estimated run time from the fallback queue and transfer them into the memory run.

The short process first (SPF) scheduling algorithm chooses a process that estimates the shortest running time from the ready queue, assigns the processor to it, causes it to execute immediately and executes until it is completed, or when an event is blocked to abort the processor and then re-dispatched.

Advantages: Average waiting time, minimum turnaround time;

Disadvantage: This algorithm is disadvantageous to long operation, and the turnaround time of long job in SJF scheduling algorithm will increase. More seriously, if there is a long job going into the system's back-up queue, because the scheduler always prioritizes those (even backward) short jobs, it will cause long jobs to not be dispatched long-term ("hunger" phenomenon , attention to differentiate "deadlock". The latter is the system ring wait, the former is the scheduling policy problem).

Average wait time t = (0+2.3+1.4+1)/4=1.175
Average turnaround time T = (2+3.3+1.9+1.2)/4=2.1
Average weighted turnaround time W = (1+3.3+3.8+6)/4=3.525

3. Time slice rotation scheduling algorithm (RR)

  The processing time of the CPU is divided into a time slice, and the process in the ready queue runs a time slice in turn. When the time slice is over, the process is forced to give up the CPU, the process goes into the ready queue, waits for the next schedule, and the process is dispatched to select a process in the ready queue, assigning it a time slice to put into operation.

In this algorithm, the system queues up all the ready processes in the order of arrival time, and the process scheduler always chooses the first process in the ready queue, i.e. the principle of first-come-first service, but only one time slice, such as 100ms, can be run. After a time slice is used, even if the process does not complete its operation, it must also release the (stripped) processor to the next ready process, and the stripped process returns to the end of the ready queue to be queued again, waiting to run again.

In the time-slice rotation scheduling algorithm, the size of the time slice has a great influence on the performance of the system. If the time slice is large enough that all processes can be executed in a single time slice, then the time-slice rotation scheduling algorithm degrades to the first-come-first service scheduling algorithm. If the time slice is small, then the processor will switch too frequently between processes, making the processor more expensive, and the actual time spent running the user process will be reduced. Therefore the size of the time slice should be chosen appropriately.

Advantages: Take into account the length of work;

Cons: The average wait time is longer, and context switching takes a lot longer. Suitable for time-sharing systems.

4. Priority scheduling algorithm (HPF)

  Each job specifies an integer that represents the priority of the job, and when a new job needs to be transferred from the input well into memory processing, the job with the highest priority is chosen.

5. Multilevel Feedback Queue scheduling algorithm

The time slice rotation is combined with the priority scheduling, the process is divided into different queues by priority, prioritized, prioritized, and rotated by time slices. The advantages are the long-term operation, good response time, feasibility, suitable for all kinds of working environment.

6. High response ratio priority scheduling algorithm

Scheduling is based on the response ratio of the formula "response ratio = (Process Execution time + process wait time)/Process Execution Time". When the high response priority algorithm is in the same waiting time, the job execution time is shorter, the response is higher, the task is satisfied, the response is larger with the waiting time, the priority is increased, and the hunger phenomenon is avoided. The advantage is that both short and long work, the disadvantage is that the calculation response is more expensive, applicable to batch processing system.

Job scheduling algorithm

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.