Operating System Concept Learning Note 3 CPU scheduling algorithm

Source: Internet
Author: User
Basic Concept 1 records in a queue are usually process control blocks of processes. 2 CPU scheduling decision can occur in the following four environments: A. When a process switches from running to waiting, for example, i/O requests or calls wait to wait for the termination of a sub-process. For example, when a process switches from the waiting state to the interrupted c state, for example, I/O completed D. When a process is terminated, the scheduling can only happen in the first and fourth situations, the scheduling scheme is not preemptible. Otherwise, the scheduling scheme can be preemptible. Non-preemptible scheduling is adopted. Once the CPU is allocated to a process, the process will continue to use the CPU until the process is terminated or switches to the waiting state to release CPU 3 allocation. Program Functions include switching context to user mode jump to the appropriate location of the user program to restart the Program II Scheduling Principle CPU usage: 40% to 90% throughput: the number of processes completed in a time unit. Turnaround time: the interval between process submission and process completion is called the turnaround time. The turnaround time is the sum of all time periods, including waiting for memory entry, waiting in the ready queue, running on CPU, and I/O running wait time: CPU scheduling Algorithm It does not affect the amount of time the process runs and executes I/O. It only affects the time spent by the process in the queue. Response time: the time from request submission to first response. Is the time required to start the response, rather than the time required to output the response. Maximum CPU usage and throughput, minimum turnaround time, wait time, and corresponding time. Three CPU scheduling algorithms: 1-first-served FCFS scheduling (first-come, first-served) when a process enters the queue, the PCB is linked to the end of the queue. When the CPU is idle, the CPU is allocated to the process in the queue header. Then, the running process is deleted from the queue. The average waiting time of the FCFS policy is quite long. The FCFS scheduling algorithm is non-preemptible. 2. How do I know the length of the next CPU request when the shortest-job-first SJF algorithm is really difficult. SJF scheduling is often used for long-term scheduling. 3. Priority Scheduling each process has a priority associated with it. processes with the highest priority will be allocated to the CPU. Processes with the same priority are scheduled in the FCFS sequence. Priority can be defined either internally or externally. Priority Scheduling can enable or disable preemption. A major problem with the priority scheduling algorithm is infinite blocking. The solution is aging. Aging is a technology that gradually increases the priority of processes waiting for a long time in the system. 4. The rotation method scheduling rotation method (RR) scheduling algorithm is specially designed for time-sharing systems. Defines a small time unit, called a time volume or time slice. The time slice is usually 10 ms to 100 ms. The ready queue is processed as a cyclic queue. The CPU scheduler needs to queue a loop, and allocate a CPU for each process that does not exceed a time interval. If the context switching time is about 10% of the time slice, about 10% of the CPU time will be wasted on context switching. 5 Multi-Level queue Scheduling (multilevel queue-scheduling algorithm) Different queues can be used for foreground and background processes. Foreground queues may use the RR Algorithm for scheduling, while backend queues may use the FCFS Algorithm for scheduling. 6 multi-level feedback queue Scheduling for multi-level queue scheduling algorithms, when a process enters the system, it is permanently allocated to a queue, and the process does not move between queues. Multi-Processor Scheduling heap into multi-processor asymmetric multi-processor five real-time scheduling real-time computing is divided into two types: hard real-time, soft real-time hard real-time: the system needs to complete key tasks within the guaranteed time. Generally, when a process is submitted, a statement tells the system the time required to complete or execute I/O. Soft Real-Time: key processes must have higher priority than other weak processes. To achieve soft real-time, you need to design the scheduling program and relevant aspects of the operating system: first, the system must have priority scheduling, and the real-time process must have the highest priority. The priority of a real-time process does not decrease with time, although the priority of a non-real-time process is acceptable. Second, the allocation latency must be limited to the time it takes for the dispatcher to stop a process and start another process to execute it. 6. linuxlinux provides two independent process scheduling algorithms. One is a time-sharing algorithm used for fair and preemption among multiple processes. The other is designed for real-time tasks, linux only allows processes running in user mode to be preemptible. The first scheduling type is used for time-based processes. For traditional time-based processes, Linux uses a priority-based and credit-based algorithm. Each process has a certain amount of scheduling credit. When the party chooses a new task to run, the process with the highest credit will be selected. Every time a timer is interrupted, the current running process will lose a credit. When the Party's credit is 0, it will be suspended and another process will be selected. Linux uses two types of real-time scheduling: first-come-first-served and round-robin. Time slice rotation (RR) scheduling is more suitable for time-sharing systems. The FCFS algorithm is not preemptible, And the RR algorithm is preemptible. SJF and priority algorithms can be preemptible or non-preemptible. Multi-level queue algorithms allow different algorithms to be used for various types of processes. The most common algorithms are foreground interactive Queue (RR) and backend batch Queue (FCFS ). Multi-level feedback queue allows Process Migration between queues. Both Solaris 2 and Windows adopt preemptible and priority-based scheduling algorithms, including support for Real-Time Thread Scheduling. Linux Process Scheduling programs also use priority-based algorithms and provide real-time support.

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.