A discussion on "Job scheduling" and "process scheduling"

Source: Internet
Author: User
Tags cpu usage

Title: (Peking University 1993 postgraduate)

In a batch system, there are two job processes. There is a job sequence, arrival time and estimated service time as follows. The system adopts the job scheduling algorithm with the highest response priority, and the job process scheduling adopts the preemptive scheduling algorithm with short job priority. Please list the performance tables for each job.

====================================================================

Process scheduling is divided into

Long-range scheduling , also known as job scheduling, is used to determine which jobs in the fallback queue on the external memory are transferred into memory, create processes for them, allocate the necessary resources, and then queue the newly created processes on the Ready queues for execution

short-range scheduling , also known as process scheduling, is used to determine which process in the ready queue should receive the processor, and then the dispatcher assigns the processor to the specific operation of the process

Medium -range scheduling, from ready pending to ready, from blocking to blocking, introducing the primary purpose of medium-range scheduling to improve memory utilization and system throughput (not discussed here)

Process scheduling diagram:

When a job arrives, it is first placed in the fallback queue.

Job scheduling selects the resources to be satisfied from the backup queue by a certain algorithm to get the job loaded into memory, so that the job has the opportunity to occupy the processor execution.

The so-called opportunity, because then also need process scheduler to schedule, decide which process priority to get the CPU, when to get the CPU, allocate how much CPU time slice, can preempt and so on, that is, the dispatcher is the brain, the CPU is just an executive part only.

Therefore, when a job is scheduled to be selected and loaded into memory, a process is created for the job, and if multiple jobs are loaded into memory, multiple processes exist in memory, the initial state of which is ready, placed in the ready queue, and then By the process scheduler according to its own scheduling algorithm to select the current processor-based process, the process will appear in various states, the following States will cause the scheduler to reschedule the decision:

1. After you create a new process, you need to decide whether to run the parent process or the child process

2. A process needs to be re-dispatched to the CPU at the end of a process running out of CPU usage

3. When a process is blocked on an I/O signal or semaphore or other, you must select another process to run.

4. When an I/O interrupt occurs, some blocked programs that wait for the I/O may already be in the ready state, requiring a re-decision.

Scheduling algorithm is divided into preemptive and non-preemptive algorithm two categories, here to distinguish:

non-preemptive: means that the scheduler schedules a process to run, allocates time slices, until the time slice is over or the process itself interrupts its execution for some reason, or the scheduler cannot forcibly schedule another process to preempt the CPU resources of the original process because of priority.

preemptive: means that the scheduler has dispatched a process to run, but since then the scheduler has been able to force another priority-compliant process to take its CPU resources out of its algorithm at any time.

So, job scheduling and process scheduling cooperate with each other to realize the parallel execution of multi-channel operation.

So why do you have to make job scheduling algorithms? Why do we have a backup queue? Just throw it in the ready queue when a job arrives, okay? The reason we don't actually do this is that the space for the ready queue may be limited. For example, the topic says there are two job processes, stating that the capacity of the ready queue is 2, one job runs, and one job is ready. Since not every job can quickly reach the ready state, job scheduling is required to select jobs that enter the system (ready state).

The solution is as follows:

10:00 job a arrives because the ready queue is empty, the job is dispatched into the system, and the process is scheduled to execute

10:10 Job B arrives, the ready queue is not full, the job is dispatched into the system, because B is the shortest job at this time, so the process dispatch A to the ready state, scheduling B execution

Job A has been running for 10 minutes and the remaining 25 minutes

10:15 Job C arrives, response ratio is 1, wait for job to dispatch into system

Job B continues execution, has been running for 5 minutes, remaining 25 minutes

Job a remains 25 minutes in the ready queue

10:20 Job D arrives, response ratio is 1, wait for job to dispatch into system

Job C waits 5 minutes, response than R=1+5/45 = 1.11

Job B continues execution, has been running for 10 minutes, remaining 20 minutes

Job a remains 25 minutes in the ready queue

10:30 job E arrives, response ratio is 1, wait for job to dispatch into system

Job D waits 10 minutes, response than R=1+10/20 = 1.5

Job C waits 15 minutes, response than R=1+15/45 = 1.3

Job B continues execution, has been running for 20 minutes, remaining 10 minutes

Job a remains 25 minutes in the ready queue

10:40 Job E Wait 10 minutes, response than R=1+10/30 = 1.3

Job D waits 20 minutes, response than R=1+20/20 = 2.0

Job C waits 25 minutes, response than R=1+25/45 = 1.6

Job D has the highest response ratio, D is dispatched into the system by the job, because it is the shortest job, the process scheduler D executes

Job B Run End

Job a remains 25 minutes in the ready queue

11:00 Job E Wait 30 minutes, response than R=1+30/30 = 2.0

Job C waits 45 minutes, response than R=1+45/45 = 2.0

Both responses are the same, because C arrives first, so the job scheduler C-System

Job D runs for 20 minutes, end of run

Job a remains 25 minutes, service time is smaller than C, process schedule a executes

11:25 Job E Wait 55 minutes, response than R=1+55/30 = 2.8, job scheduling into the system

Job C 45 minutes remaining in the ready queue

Job a runs for 25 minutes, end of run

Because C service time is longer than E, process dispatch e executes

11:55 Job C 45 minutes remaining in the ready queue

Job e runs for 30 minutes, end of run

12:40 Job C Run End

Each job run time period is:

A 10:00-10:10 11:00-11:25

B 10:10-10:40

C 11:55-12:40

D 10:40-11:00

E 11:25-11:55

A discussion on "Job scheduling" and "process scheduling"

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.