linux2.4 to linux2.6 Kernel dispatch (3) __linux

Source: Internet
Author: User

The arrays two-dollar array is a container for two types of Ready queues, and active and expired point to one of them respectively. Once a process in active has run out of its own time slice, it is transferred to the expired and the new initial time slice is set, and when active is empty, the current time slice of all the processes is consumed, and the active and expired are swapped at once. Re-start the next round of time sheet decrement (see "Scheduler").

Recall 2.4 Scheduling system, Process time slice calculation is more time-consuming, in the early kernel version, once the time slice is depleted, in the clock interrupt recalculation time slice, later in order to improve efficiency, reduce clock interrupt processing time, 2.4 The scheduling system is once again in the scheduler after all the time slices of the ready process have been depleted. This is also an O (n) magnitude process. In order to ensure that the scheduler of O (1) is executed, 2.6 of the time slice is performed separately on each process depletion time, and the rotation of the time slice is accomplished through the simple reversal described above (see "Scheduler"). This is another 2.6 scheduling system of a bright spot.

2) spinlock_t lock

Runqueue spin locks, which should still be locked when operating on runqueue, but this locking operation only affects a ready queue on one CPU, so the probability of competition happening is much smaller.

3) task_t *curr

The process that this CPU is running.

4) tast_t *idle

A idle process that points to this CPU, equivalent to the role of INIT_TASKS[THIS_CPU () in 2.4.

5) int Best_expired_prio

Record the highest priority in the expired-ready process group (lowest value). The variable is saved (Schedule_tick ()) when the process enters the expired queue (for the purpose of "Expired_timestamp").

6) unsigned long expired_timestamp

When a new round of time flakes begins, this variable records the time at which the earliest process consumes the time slice event (the absolute value of the jiffies, which is assigned in Schedule_tick ()), which is used to characterize the maximum wait time for the ready process in expired. Its use is embodied in expired_starving (RQ) macros.

As mentioned above, two ready queues, active and expired, are maintained on each CPU. Typically, a process that ends the time slice should be transferred from the active queue to the expired queue (Schedule_tick ()), but if the process is an interactive process, the scheduler keeps it on the active queue to increase its response speed. Such a measure should not allow other ready processes to wait too long, that is, if the process in the expired queue has been waiting long enough, even the interactive process should be transferred to the expired queue to empty active. This threshold is reflected in the expired_starving (RQ): In the Expired_timestamp and starvation_limit are not equal to 0, if the following two conditions are met, then Expired_starving () return true:

(Current absolute time-Expired_timestamp) >= (the total number of all ready processes in Starvation_limit * queue + 1), which means that at least one process in the expired queue has been waiting long enough;

The static priority of the running process is lower than the highest priority in the expired queue (Best_expired_prio, the value is large), then of course you should empty the active switch to expired as soon as possible.

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.