I. Differences in process and operations
Difference: A process is a single execution of a program on a data set, and a job is a task that the user submits to the system.
Relationship: A job usually consists of several processes, and several processes work together to complete a task, that is, a job.
Job scheduling is a macro-scheduling, which determines which job can enter main memory. Process scheduling is a micro-dispatch, which determines which process in each job occupies the central processing unit.
Second, first come first service and short job (process) Priority scheduling algorithm
① first come first service (FCFS)
Can be used for job scheduling and process scheduling, in short, each schedule is to select one or more jobs from the fallback job queue that first enter the queue, transfer them into memory, assign resources to them, create processes, and put them in the ready queue. When using the FCFS algorithm in process scheduling, each schedule is to select a process from the ready queue that is first entered into the queue , assign a processor to it, run it, and then abort the processor until it has completed or has been blocked by an event. It is one of the simplest scheduling algorithms.
② short Job (process) first
Short job (process) Priority scheduling algorithm SJ (P) F, refers to the algorithm for short or short process priority scheduling. They can be used for job scheduling and process scheduling, respectively. 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.
Both of these algorithms are executed until the process or job is assigned to the processor, until it is completed or blocked and the processor is discarded.
Three, high priority priority scheduling algorithm
① Priority scheduling algorithm
A. Non-preemptive priority algorithm
Once the system has allocated the processor to the highest-priority process in the ready queue, the process continues until it is completed or blocked , and the system can then reassign the processor to another process with the highest priority. This scheduling algorithm is mainly used in batch processing systems, and can also be applied to some real-time systems where real-time requirements are not stringent. Batching refers to the user who submits a batch of jobs to the operating system and then no longer intervenes, and the operating system controls them to run automatically. Real-time system refers to the correctness of calculation not only depends on the logic correctness of the program, but also depends on the time of the result, if the time constraints of the system are not satisfied, the system error will occur.
B. Preemptive priority algorithm
After the system assigns the processor to the process with the highest priority, the process scheduler stops the current process and re-assigns the processor to the highest-priority process when there is a process in the ready queue that is higher than the priority of the current execution process . This preemptive priority scheduling algorithm can better meet the requirements of urgent operation, so it is often used in the demanding real-time systems, as well as in batch processing and timeshare systems with higher performance requirements.
② High response ratio priority scheduling algorithm
priority = (wait time + service time)/service time.
(1) If the waiting time of the job is the same, the shorter the service time, the higher the priority, and therefore the algorithm is advantageous to the short job.
(2) When the time required for the service is the same, the priority of the job depends on its waiting time, the longer the waiting time, the higher the priority, so it realizes the first to serve first.
(3) For long jobs, the priority of the job can increase with the waiting time, and when its waiting time is long enough, its priority can be raised to high, thus also can obtain the processor. In short, the algorithm not only takes care of the short work, but also takes into account the order of the arrival of the operation, will not make long work long-term service. Therefore, the algorithm realizes a good tradeoff. Of course, when using this algorithm, the response ratio calculation must be done before each dispatch, which increases the system overhead.
Four, time-slice-based rotation scheduling algorithm
1. Time Slice Rotation method
The system queues all the ready processes on a first-come-first-served basis, allocating the CPU to the team's first process and making it perform a time slice each time it is scheduled. The size of the time slice is from several ms to hundreds of Ms. when the elapsed time slice runs out , the clock interrupt request is made by a timer, which signals the scheduler to stop the execution of the process and sends it to the end of the ready queue, and then assigns the processor to the new team first process in the ready queue, while also allowing it to execute a time slice. This ensures that all processes in the ready queue can receive a time slice of processor execution times within a given time. In other words, the system can respond to requests from all users within a given time.
2. Multilevel feedback queue scheduling algorithm
With n queues (q1,q2 .... QN), priority order (Q1) > Priorities (Q2) > > First (QN).
The time slices for each queue are reduced as the priority increases , that is, the shorter the time slice in the queue with the higher priority.
When the ① process enters the queue to be dispatched, it first waits for the highest priority Q1.
② first schedules the processes in the queue with high priority. If there are no scheduled processes in the queue in high priority, the processes in the secondary priority queue are dispatched. For example: Q1,q2,q3 three queues, only when there is no process waiting in the Q1 to dispatch Q2, in the same way, only q1,q2 are empty when the Q3 will be dispatched.
③ for each process in the same queue, it is scheduled according to the time slice rotation method. For example, the time slice of the Q1 queue is N, then Q1 in the job after n time after the film has not been completed, then into the Q2 queue waiting, if the Q2 time slice run out after the job can not be completed, has entered the next level of the queue until the completion.
④ a process in a low-priority queue runs with a newly arrived job, the CPU is immediately assigned to the newly arrived job (preemption) after the time slice is run.
The multi-level feedback queue scheduling algorithm can not only get high priority jobs to respond, but also make short jobs (processes) complete quickly.
A common process scheduling algorithm