struct task_struct {
...
int prio, static_prio, normal_prio;
unsigned int rt_priority;
struct list_head run_list;
const struct sched_class *sched_class;
struct sched_entity se;
unsigned int policy;
cpumask_t cpus_allowed;
unsigned int time_slice;
...
}
|
step 1: prio and
normal_prio indicate dynamic priority;
static_prio indicate static priority.
Static priority is assigned when process was created.
normal_prio denotes a priority that is computed based on the static priority and scheduling policy of process.
Identical static priorities will therefore result in different normal priorities depending on whether a process is a regular or a real-time process. When a process forks, the child process will inherit the normal priority.
However, the priority considered by the scheduler is kept in prio. A third element is required because situations can arise in which the kernel needs to temporarily boost the priority of a process. Since these changes are not permanent, the static and normal priorities are unaffected by this.
STEP 2: rt_priority denotes the priority of a real-time process. Note that this does not replace the previously discussed values! The lowest real-time priority has value 0, whereas the highest priority is 99. Higher values correspond to higher priorities. The convention used here is different from the convention used for nice values.
STEP 3: sched_class denotes the scheduler class the process is in.
STEP 4: se is embed in task_struct, on which scheduler operate on.
STEP 5: policy holds the scheduling policy applied to the process. Linux supports five possible values:
- SCHED_NORMAL is used for normal processes on which our description focuses.
- SCHED_BATCH is for CPU-intensive batch processes that are not interactive.
- SCHED_IDLE tasks will also be of low importance in the scheduling decisions, but this time because their relative weight is always minimal.Note that SCHED_IDLE is, despite its name, not responsible to schedule the idle task.
- SCHED_RR implements a round robin method.
- SCHED_FIFO uses a first in, first out mechanism.
SCHED_RR and SCHED_FIFO are used to implement soft real-time processes, others for CFS scheduling.
STEP 6: cpus_allowed is a bit field used on multiprocessor systems to restrict the CPUs on which a process may run.
STEP 7: run_list and
time_slice are required for the round-robin real-time scheduler, but not for the completely fair scheduler. run_list is a list head used to hold the process on a run list, while time_slice specifies the remaining time quantum during which the process may use the CPU.
阅读(928) | 评论(1) | 转发(0) |