First, the common batch processing job scheduling algorithm
1. First come first service scheduling algorithm (FCFS): is according to each job into the system's natural order to dispatch the job. 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.
2. Short Job priority scheduling algorithm (SPF): is the priority of scheduling and processing of short jobs, so-called short refers to the operation of short-run time. When the job is not running, it does not know how long it actually runs, and therefore requires the user to submit an estimate of the job's run time at the time of the job submission.
3. Maximum response ratio priority algorithm (HRN):FCFS may cause short-term job users dissatisfaction, SPF may make long-working users dissatisfied, so proposed HRN , select a response that is higher than the highest job run. Response than =1+ job wait time/job processing time.
4. Priority-based scheduling algorithm (HPF): Each job specifies an integer that represents the priority of the job, and the job with the highest priority is selected when a new job needs to be entered and transferred into memory processing.
5. Equalization Scheduling algorithm, that is, multi-level queue scheduling algorithm
Basic concepts:
Job turnaround time (Ti) = Finish Time (Tei)-Submission time (TSI)
Job average turnaround time (T)= turnaround time/number of jobs
job with right turnaround time (Wi) = turnaround time/Run time
Response ratio = (wait time + run time)/ run time
Second, process scheduling algorithm
1. FIFO algorithm: Select according to the order in which the process enters the ready queue. That is, whenever the process is dispatched, the first team of the ready queue is always put into operation.
2. time slice rotation algorithm (RR): A scheduling algorithm for timeshare systems. The basic idea of rotation is to divide the processing time of the CPU into a time slice, in which the processes in the ready queue run 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.
3. Highest-priority algorithm (HPF): process scheduling assigns a processor to a ready process with the highest priority each time. The highest-priority algorithm can be combined with different CPUs to form a preemptive highest-priority algorithm and a non-preemptive highest-priority algorithm.
4. Multi-level queue feedback method: Several scheduling algorithms of the combined form of multi-level queue mode.
Three, free partition allocation algorithm
1. First adapt the algorithm: When receiving a memory request, find the partition description table, find the first free area to satisfy the request length, divide and allocate it. This algorithm is simple and can make allocation decisions quickly.
2. best Fit algorithm: when the memory request is received, find the partition description table, find the first minimum idle area that can satisfy the request length, divide and allocate it. This algorithm is the most space-saving, because it tries not to split into large idle areas, the disadvantage is that it may form a lot of small free partitions, called "Fragments."
3. worst-fit algorithm: when receiving a memory request, look for the partition description table and find the largest free area that can satisfy the request. The advantage of this algorithm is to avoid the formation of fragments, and the disadvantage is that after splitting the large idle area, when encountering a large program to request memory, the possibility of not satisfied.
Iv. page replacement algorithm in virtual page storage Management
1. ideal page replacement algorithm (OPT): This is an ideal algorithm that cannot be implemented in practice. The idea of this algorithm is: When a page fault occurs, select the memory pages that will never be used or are no longer accessed in the longest time.
2. FIFO page replacement algorithm: Select the first page to enter the memory to be eliminated.
3. The most recent unused algorithm (LRU): Choose a page that has been unused for the longest time in a recent period and retire it.
4. Minimum usage algorithm (LFU): Select the page conversion that is least visited until the current time.
Five, disk scheduling
1. first come first served (FCFS): is to start the disk drive in the order in which they are requested, regardless of the physical location they want to access
2. Shortest seek time first (SSTF): Lets the requesting visitor that is closest to the current track start the disk drive, That is, the shortest time to find the job performed first, regardless of the order of arrival of the requesting visitor, thus overcoming the problem of the magnetic arm moving too large in the first come first service scheduling algorithm
3. Scanning algorithm (scan) or elevator scheduling algorithm: always start at the current position of the magnetic arm and select the visitor to the cylinder closest to the current one, along the direction of the magnetic arm movement. If no access is requested along the direction of the magnetic arm, the direction of movement of the magnetic arm is changed. In this scheduling method, the movement of the magnetic arm is similar to the dispatch of an elevator, so it is also called the elevator scheduling algorithm.
4. cyclic scanning algorithm (Cscan): The cyclic scanning scheduling algorithm is improved on the basis of scanning algorithm. The magnetic arm changes to a single movement, by the outward. The current position begins to select the visitor of the cylinder closest to the current one, along the direction of the magnetic arm movement. If there is no request to access along the direction of the magnetic arm, then back to the most, the job request to access the minimum cylinder number.
This paper focuses on the following process scheduling algorithms:
1 . Types of priority scheduling algorithms
The highest priority (FPF) scheduling algorithm is introduced in order to take care of the urgent operation, so that it gets preferential treatment after entering the system . This algorithm is often used in batch processing system, as a job scheduling algorithm, also as a process scheduling algorithm in a variety of operating systems, can also be used in real-time systems. When the algorithm is used for job scheduling, the system will select several higher priority jobs to load the memory from the fallback queue. When used for process scheduling, the algorithm is to assign the processor to the ready queue of the highest priority process, at this time, the algorithm can be further divided into the following two kinds.
1) non-preemptive priority algorithm
In this way, once the system has allocated the processor to the highest priority process in the ready queue, the process continues until it is completed, or the system can reassign the processor to another process that has the highest priority because of an event that causes the process to abandon the processor. 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.
2) preemptive priority scheduling algorithm
in this way, the system also assigns the processor to the process with the highest priority and makes it execute. During its execution, however, as long as another process of higher priority arises, the process scheduler immediately stops the execution of the current process (formerly the highest priority) and re-assigns the processor to the new priority process. Therefore, when a new ready process I is present in the system, the priority pi is compared with the priority PJ of the executing process J when this scheduling algorithm is used. If PI≤PJ, the original process PJ will continue to execute, but if it is PI>PJ, then immediately stop the execution of PJ, do a process switch, so that I process into execution. Obviously, this preemptive priority scheduling algorithm can better meet the requirements of urgent operation, so it is often used in the demanding real-time system, and in the batch processing and timeshare system with high performance requirements.
2 . High response ratio priority scheduling algorithm
in batch processing system, the short job first algorithm is a better algorithm, and its main disadvantage is that the operation of long operation is not guaranteed. If we can introduce the dynamic priority described above for each job, and the priority of the job increases with the wait time to increase at rate a , then the long job waits for a certain period of time, there must be a chance to assign to the processor. The change law of this priority can be described as:
As the sum of waiting time and service time is the response time of the system to the job, the priority is equal to the response than the RP. Accordingly, it can also be expressed as:
Priority = (wait time + request service time)/request service time;
Rp= (Waiting time + request service time)/Request Service time = response Time/request service time;
It can be seen from the above formula:
(1) If the waiting time of the job is the same, the shorter the service time and the higher the priority, 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 is first to serve first.
(3) for a long job, the priority of the job can increase with the wait time, and when its wait time is long enough, its priority can rise to high, which can also get 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 achieves a good compromise. Of course, when using this algorithm, the response ratio calculation must be done before each dispatch, which increases the system overhead.
3 . Multilevel feedback queue scheduling algorithm
Multi-level feedback queue scheduling algorithm does not need to know the execution time of various processes in advance, but also can satisfy the needs of various types of processes, so it is now recognized as a good process scheduling algorithm. In the system using multilevel feedback queue scheduling algorithm, the implementation process of scheduling algorithm is described below.
(1) set up multiple ready queues and assign different priorities to each queue. The first queue has the highest priority, the second queue is followed, and the priority of the remaining queues is lowered one by one. The algorithm gives each queue the size of the process execution time slices, and in the higher priority queue, the execution time slices for each process are smaller. For example, the time slice of the second queue is one times longer than the time slice of the first queue..., the time slice of the i+1 queue is one times longer than the time slice of the I queue.
(2) when a new process enters memory, it is first placed at the end of the first queue and queued for dispatch by the FCFS principle. When it is time for the process to execute, it can prepare the evacuation system if it can be completed on the chip, and if it is not completed at the end of a time slice, the scheduler moves the process to the end of the second queue, and then similarly waits for dispatch execution by the FCFS principle, if it is still not completed after running a time slice in the second queue Then put it in the third queue, ..., and so on, when a long job (process) from the first queue down to the nth queue, in the nth queue will be taken by the time slice rotation operation.
(3) The scheduler dispatches the processes in the second queue only when the first queue is idle, and only if the 1th~ (i-1) queue is empty, the process in queue I is scheduled to run. If the processor is servicing a process in queue I, and a new process enters a higher priority queue (1~ (i-1)), then the new process will preempt the processor that is running the process, that is, the scheduler puts the running process back to the end of the queue. Assign the processor to the new high priority process.
Baidu interview (process scheduling, scheduling algorithm)