linux2.4 to linux2.6 kernel dispatch (2) __linux

Source: Internet
Author: User
Tags array example

1) prio_array_t *active, *expired, arrays[2]

The most critical data structure in the Runqueue. The ready queue for each CPU is divided into two parts by the time slice, accessed through active pointers and expired pointers, active pointing to the time slice, the currently scheduled ready process, expired the ready process that the time slice has run out. Each class of readiness process is represented by a struct Prio_array structure:

struct Prio_array {

int nr_active; * * Number of processes in this process group * *

                                            struct list_head queue[MAX_PRIO];

                                                                                                                                                      /*   The  HASH  table with priority index, see below  */

                                            unsigned long bitmap[BITMAP_SIZE];

/* Accelerate the above HASH table access Bitmap, see below * *

};

figure 1:active, expired array Example



The task in the diagram is not the TASK_STRUCT structure pointer, but the task_struct::run_list, which is a little trick, as explained in Run_list below.

In the 2.4 version of the kernel, the process of finding the best candidate readiness process is done in the Scheduler schedule (), with each schedule (called goodness () in the For Loop), which is related to the number of currently ready processes, so the time taken to find is O (n Level, n is the number of currently ready processes. Because of this, the execution time of the dispatch action is related to the current system load and cannot be given a limit, which is contrary to the requirement of real-time.

In the new O (1) Schedule, this lookup process is decomposed into n steps, and each step takes an O (1) magnitude.

The Prio_array contains a ready queue array whose index is the priority of the process (a total of 140 levels, as described in the "Static_prio" attribute), and processes of the same priority are placed in the linked list queue of the corresponding array element. The first item in the list with the highest priority in the ready queue active is directly given as a candidate process (see "Scheduler"), while the priority calculation process is distributed throughout the process (see "Optimized priority calculation Method").

To speed up the search for a list of existing ready processes, the 2.6 core establishes a bit-mapped array to correspond to each priority list, if the priority list is non-null, the corresponding bit is 1, or 0. The core also requires that each architecture construct a sched_find_first_bit () function to perform this search operation, quickly locating the first non-empty ready process list.

This algorithm, which is decentralized in the centralized computing process, ensures the time limit for the scheduler to run, while preserving richer information in memory also accelerates the process of candidate process localization. This change is simple and efficient, one of the highlights of the 2.6 kernel.

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.