First, the process of scheduling and timing functions
Process scheduling: the process of scheduling functions performed by the operating system process scheduler
Specific tasks: according to some strategies and algorithms to select a new process running on the CPU, which is currently free from the ready state process.
Process scheduling time: normal or abnormal process ends, the process to block the arrival of a higher priority process, still pictures when the time runs out will result in the scheduling process.
Second, the process of scheduling algorithm
What kind of algorithm is a good algorithm?
- Turnaround time is short: submit jobs to the system from the beginning, to complete the job, it takes a short time
- Fast response time: submit jobs to start from the user, the system begins to respond, spent a short time
- As of the time of guarantee: guaranteed job before the start of the "Start deadline" before the "deadline for completing the" complete
- High system throughput: amount OS completed within unit time,
- Good processor utilization: CPU utilization as high as possible
Process scheduling algorithm:
First come first serve scheduling algorithm (FCFS ): first to reach the process ready queue of ready queue first team selection, the process for the allocation of CPU
Turnaround time turnaround time = process
System = average turnaround time turnaround time of all processes and then dividing by the number of processes
Time with full w = average turnaround time turnaround time of each process is divided by the service process, and then adding the last process divided by the number
Disadvantages: process serving time period to wait for a long time, the whole long turnaround time.
Short process priority scheduling algorithm (SPF) : the shortest running time estimate process from the ready queue, allocating CPU to the process
Advantages: Compared with the FCFS algorithm, short process priority algorithm can effectively reduce the average waiting time processes, improving system throughput
Cons: unfavorable long process; no guarantee that urgent treatment process; estimate the length of the process by the user, not necessarily accurate.
Priority scheduling algorithm : the system CPU allocated to the highest-ready process queue priority
- Non-preemptive: During operation, the arrival of a higher priority process, it can not deprive CPU
- Preemptive: During operation, the arrival of a higher priority process, we can seize the CPU
Priority type
- Static priority: When you create a determined, remains unchanged during operation
- Dynamic priority: created to determine, as the process of promoting change or waiting time increases
The algorithm problems: endless obstruction (hunger); solution to the problem (aging technology): Increases the priority waiting time is very long process of
round-robin scheduling algorithm (RR):
The system will process all ready by the principle of first come, first served, arranged in a queue, each time the CPU scheduling process given to the first team, and ordered him to perform a time slice. When the time slice expires, the scheduler terminate execution of the current process, and is sent to the tail of the ready queue.
1, a small time slice is determined zoomed
T = Nq T: system response time N: the number of processes q: timeslice
- The system response time requirements of: response time requirements, the smaller the time slice
- The number of ready queue process: the more the number of processes, the smaller the time slice
- The processing capability of the system: the better processing capacity, the smaller the time slice
Multilevel queue scheduling algorithm: the ready queue attention immediately divided into separate queues, each with its own scheduling algorithm
A high priority queue p1, p2, p3, p4
A low priority queue p5, p6, p7
Multilevel feedback queue scheduling algorithm : establishing a plurality of different priority ready queue, each queue has a different size time slices
The higher the priority queue, the shorter the time slice
The lower the priority queue, the longer the time slices
Third, real-time scheduling system
The basic conditions for real-time scheduling:
1, to provide the necessary scheduling information: time ready to start deadline, the deadline for completing the processing time, resource requirements, priorities
2, the processing capability the system: Assuming that the system has m periodic real processes that processing time can be expressed as Ci, Pi the cycle time is expressed as, in the case of a single processor, the following equation must satisfy the constraint condition:
3, preemptive scheduling mechanism (the most widely used method)
4, with fast switching mechanism: the external interrupt ability to respond quickly to rapid process of switching capacity
Common real-time scheduling algorithm :
1, the earliest deadline first algorithm EDF (Taobao Jingdong &): Start off sooner, the higher the process priority, priority access to the CPU
2、最低松弛度优先算法LLF:根据实时进程的紧迫程度来进行调度的算法
四、进程切换
五、 多处理器调度
六、 死锁