Talk about sched_rr and sched_fifo

Source: Internet
Author: User

When we use pthread to create a thread, we can specify the scheduling policy-sched_other (default), sched_rr, and sched_fifo. Here we will talk about two real-time policies: sched_rr and sched_fifo.

Let's take a look at the effect. We have created four sub-threads to specify the highest priority (for specific policies ):

    • Sched_rr


    • Sched_fifo


For tasks with the same priority, sched_rr is assigned to each task a specific time slice and then rotated and executed in turn. sched_fifo is used to schedule the next task after the task is executed, the order is based on the order of creation. Sched_rr schedules a thread based on the time slice. When the time slice is used up, no matter how high the thread priority is, it does not run, but enters the ready queue, waiting for the next time slice to arrive. However, as shown in figure 1, when the thread5798 time slice is used up, the thread immediately preempys the preemption and obtains a time slice.. By the way, the length of time slice is determined by Linux's experience, that is, a time slice that can be as long as possible and maintain a good time.

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.