Brief introduction of kernel learning process Scheduler

Source: Internet
Author: User
Tags require linux

Multi-task operating systems can be divided into non preemptive multitasking and preemptive multitasking. Like most modern operating systems, Linux also uses preemptive multitasking mode. This means that the time the task takes CPU is determined by the scheduler.

Scheduling policy:

Deciding when and how to choose a new process on which CPU to run for how long is called a scheduling policy.

Typically, what scheduling policy is used is related to the type of process. Processes are often divided into CPU consumption and IO consumption types.

Another type of classification is:

1, interactive process (interactiveprocess): Such processes require a large number of human-computer interaction, such a process will continue to sleep, waiting for keyboard and mouse operation to wake it up. Such processes require a high response time for the system. A typical process, such as a text-editing program.

2. batch processing (batch process): Such processes do not require human-computer interaction, often in the background process, can endure the slow response, such as compilers.

3. Real-time processes (real-time process): Such processes require a high response time for the system. such as video audio playback software.

Note: In order to correspond to real-time processes, interaction processes and batch processes are often referred to as common processes.

Policy flags:

Sched_normal: The default scheduling strategy, named Sched_other in the old version, time-sharing scheduling strategy

Sched_batch: for batch processes.

Sched_idle: Processes that use this scheduler have the lowest priority. Introduced in the implementation of CFS.

Sched_fifo: Advanced first out strategy for real-time processes. Once the CPU is occupied, it continues until a higher priority process or itself discards the CPU. Suitable for a process with high time requirements, short each time running.

SCHED_RR: A time slice rotation strategy for real-time processes. When the time slice of the process is exhausted, the system assigns it a time slice and places it at the end of the queue. This allows each process to run for a period of time. Applies to processes that take longer to execute each time.

Summary: Sched_normal,sched_batch,sched_idle: Both are used with ordinary processes. Difference: Sched_normal is the default scheduling policy. Sched_batch is used with batch processes. Sched_idle is used for the lowest-priority background program. Sched_normal and Sched_batch Beg to differ only when awakened. Waking a more frequent process is not suitable for sched_batch. The scheduling strategy used by the process is reflected in the policy, whose value is the value above. The child process inherits the policy of the parent process. At the same time, we can modify it by Sched_setscheduler.

All tasks are based on the Linux time-sharing scheduling strategy.

1, create tasks Specify a time-sharing scheduling policy and specify the priority nice value ( -20~19).

2, the execution time on the CPU (counter) is determined based on the nice value of each task.

3, if the resource is not waiting, the task is added to the ready queue.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/unix/

Related Article

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.