Processor scheduling hierarchy

Time:2021-7-26

From submission to completion, a job often goes through the following three schedules:

1、 Job scheduling

        Job scheduling is also called advanced scheduling. Its main task is to select one or more jobs from the jobs in the backup queue in external memory according to certain principles, allocate necessary resources such as memory and I / O equipment, and establish corresponding processes to enable them to obtain the rights of competitive processors. In shortScheduling of memory and external memory, each job is transferred in and out only once. Most multi-channel batch processing systems are equipped with job scheduling, while other systems usually do not need to configure job scheduling. The execution frequency of job scheduling is low and takes a long time, usually once a few minutes.

2、 Memory scheduling

        Memory scheduling is also called intermediate scheduling. The purpose of introducing intermediate scheduling is toImprove memory utilization and system throughput。 Memory scheduling transfers those processes that cannot run temporarily to external memory for waiting, and calls the process state at this time as suspended state. When the process in the suspended state can run and the memory is free, it will be redeployed into the memory, changed to the ready state, and hung on the ready queue to wait.

3、 Process scheduling

        Process scheduling is also called low-level scheduling. Its main task is to select a process from the ready queue and assign the processor to it according to some method and strategy. Process scheduling is an important part of operating systemThe most basic kind of scheduling, the execution frequency is very high and the time is short, usually every tens of milliseconds.

4、 Connection of three-level dispatching

1. Job scheduling prepares for process activities. Process scheduling makes processes active normally. Memory scheduling suspends processes that cannot run temporarily. Memory scheduling is between job scheduling and process scheduling;

2. The number of job scheduling is the least, the number of memory scheduling is slightly more, and the frequency of process scheduling is the highest;

3. Process scheduling is the most basic and indispensable.

The following two examples are analyzed:

1. There is a batch processing system with two jobs. The job scheduling adopts short job priority scheduling algorithm, and the process scheduling adopts preemptive priority scheduling algorithm. See the following table for the operation of jobs. The priority number of jobs is the priority number of processes. The smaller the priority number, the higher the priority.

Job name

arrival time

Running time

Priority number

1

8:00

40min

5

2

8:20

30min

3

3

8:30

50min

4

4

8:50

20min

6

8: 00, job 1 arrives. At this time, the memory and processor are free. Job 1 enters the memory and occupies the processor;

8: At 20:00, job 2 arrives. At this time, there is still a free position in the memory, the processor is occupied, and job 2 enters the memory. Because the process scheduling adopts preemptive priority scheduling, the corresponding process of job 2 preempts the processor;

8: At 30:00, job 3 arrives, but there is no empty memory at this time, so wait;

8: At 50 o’clock, job 2 completes execution, vacates a memory space and gives up the processor. Job 3 and job 4 compete for the memory space. Because the running time of job 4 is short, it is transferred into memory first. At this time, the corresponding process priority of job 1 is higher than that of job 4, so the corresponding process of job 1 is executed first;

9: At 10:00, the execution of job 1 is completed, a memory space is vacated and the processor is released, and job 3 is transferred to memory. Since the priority of the corresponding process of job 3 is higher than that of job 4, the corresponding process of job 3 is executed first;

10: 00, the execution of job 3 is completed and the processor is released to execute the corresponding process of job 4. At 10:20, the execution of job 4 is completed.

task

arrival time

Running time

Priority number

Memory entry time

End time

Turnaround time

1

8:00

8:00-8:20,

8:50-9:10

5

8:00

9:10

70min

2

8:20

8:20-8:50

3

8:20

8:50

30min

3

8:30

9:10-10:00

4

9:10

10:00

90min

4

8:50

10:00-10:20

6

8:50

10:20

90min

Note: turnaround time refers to the time from job submission to job completion, including the time spent waiting on the external memory backup queue, waiting in the memory ready queue, running on the processor and I / O operations.

2. In a batch processing system with two jobs, there is a job sequence. Its arrival time and estimated running time are shown in the table below. The system job adopts the highest response ratio priority scheduling algorithm (response ratio = (waiting time + estimated running time) / estimated running time). The process scheduling adopts the preemptive scheduling algorithm of short process first scheduling.

task

arrival time

Estimated running time / min

J1

10:00

35

J2

10:10

30

J3

10:15

45

J4

10:20

20

J5

10:30

30

10: 00, job J1 arrives. At this time, the memory and processor are free. Job J1 enters the memory and occupies the processor;

10: At 10:00, job J2 arrives. At this time, there is still a free position in the memory, and the processor is occupied. Therefore, job J2 is transferred into the memory to wait;

10: 15. At 10:20 and 10:30, jobs J3, J4 and J5 arrive respectively, but there are two jobs J1 and J2 in the memory when the three jobs arrive, so the three jobs cannot be transferred into the memory;

10: At 35, job J1 completes execution, vacates a memory space and gives up the processor. At this time, the response ratios of jobs J3, J4 and J5 are 65 / 45, 35 / 20 and 35 / 30 respectively, then job J4 is transferred into memory and the processor is allocated to J4 with short running time;

10: At 55, job J4 completes execution, vacates a memory space and gives up the processor. At this time, the response ratios of jobs J3 and J5 are 85 / 45 and 55 / 30 respectively, then job J3 is transferred into memory and the processor is allocated to J2 with short running time;

11: At 25:00, the execution of job J2 is completed, a memory space is vacated and the processor is released, job J5 is transferred into memory, and the processor is allocated to J5 with short running time;

11: At 55:00, the execution of job J5 is completed, the processor is released, and the processor is assigned to job J3. At 12:40, the execution of job J3 is completed.

task

arrival time

Running time

Memory entry time

End time

Turnaround time

J1

10:00

10:00-10:35

10:00

10:35

35min

J2

10:10

10:55-11:25

10:10

11:25

75min

J3

10:15

11:55-12:40

10:55

12:40

145min

J4

10:20

10:35-10:55

10:35

10:55

35min

J5

10:30

11:25-11:55

11:25

11:55

85min

Personal summary: as can be seen from the above two examples, job scheduling and process scheduling adopt different scheduling algorithms and are relatively independent. Job scheduling performs the process of transferring from the external memory backup queue to memory, while process scheduling performs the process of selecting the appropriate process from the ready queue for processor allocation. Job scheduling is preparing for process scheduling, so they are interrelated.

Source: Kingway operating system