Chinaunix首页 | 论坛 | 博客
  • 博客访问: 932604
  • 博文数量: 63
  • 博客积分: 568
  • 博客等级: 中士
  • 技术积分: 3435
  • 用 户 组: 普通用户
  • 注册时间: 2012-10-05 11:44
文章分类
文章存档

2016年(4)

2015年(6)

2014年(3)

2013年(27)

2012年(23)

分类: LINUX

2012-12-02 22:27:09

4. 调度相关的数据结构

 
/* CFS-related fields in a runqueue */ 
struct cfs_rq
{
    struct load_weight load;      /*运行负载*/ 
    unsigned long nr_running;     /*运行进程个数*/ 
 
    u64 exec_clock;
    u64 min_vruntime;             /*保存的最小运行时间*/ 
 
    struct rb_root tasks_timeline; /*运行队列树根*/ 
    struct rb_node *rb_leftmost;  /*保存的红黑树最左边的节点,这个为最小运行时间的节点,当进程
                                   选择下一个来运行时,直接选择这个*/ 
 
    struct list_head tasks;
    struct list_head *balance_iterator;
 
    /*
     * 'curr' points to currently running entity on this cfs_rq.
     * It is set to NULL otherwise (i.e when none are currently running).
     */ 

    /*current目前执行的进程,nextlast在调度的时候有用*/ 
    struct sched_entity *curr, *next, *last; 

  
 
    unsigned int nr_spread_over;
 
#ifdef CONFIG_FAIR_GROUP_SCHED
    struct rq *rq;    /* cpu runqueue to which this cfs_rq is attached */ 
 
    /*
     * leaf cfs_rqs are those that hold tasks (lowest schedulable entity in
     * a hierarchy). Non-leaf lrqs hold other higher schedulable entities
     * (like users, containers etc.)
     *
     * leaf_cfs_rq_list ties together list of leaf cfs_rq's in a cpu. This
     * list is used during load balance.
     */ 
    struct list_head leaf_cfs_rq_list;
    struct task_group *tg;    /* group that "owns" this runqueue */ 
 
#ifdef CONFIG_SMP
    /*
     * the part of load.weight contributed by tasks
     */ 
    unsigned long task_weight;
 
    /*
     *   h_load = weight * f(tg)
     *
     * Where f(tg) is the recursive weight fraction assigned to
     * this group.
     */ 
    unsigned long h_load;
 
    /*
     * this cpu's part of tg->shares
     */ 
    unsigned long shares;
 
    /*
     * load.weight at the time we set shares
     */ 
    unsigned long rq_weight;
#endif 
#endif 
};
 

 
/*
* CFS stats for a schedulable entity (task, task-group etc)
*
* Current field usage histogram:
*
*     4 se->block_start
*     4 se->run_node
*     4 se->sleep_start
*     6 se->load.weight
*/ 
struct sched_entity
{
    struct load_weight    load;        /*对整个运行队列上的负载的贡献 */ 
    struct rb_node        run_node;   /*红黑树的节点*/ 
    struct list_head    group_node;
    unsigned int        on_rq;      /*表示在运行队列上*/ 
 
    u64            exec_start;         /*最近一次开始调度的时间在update_current中会被更新*/ 
    u64            sum_exec_runtime;   /*总共在cpu上消耗的时间*/ 
    u64            vruntime;           /*cpu上运行的虚拟时间,和进程的优先级有关*/ 
    u64            prev_sum_exec_runtime;
 
    u64            last_wakeup;
    u64            avg_overlap;
 
#ifdef CONFIG_SCHEDSTATS
    u64            wait_start;
    u64            wait_max;
    u64            wait_count;
    u64            wait_sum;
 
    u64            sleep_start;
    u64            sleep_max;
    s64            sum_sleep_runtime;
 
    u64            block_start;
    u64            block_max;
    u64            exec_max;
    u64            slice_max;
 
    u64            nr_migrations;
    u64            nr_migrations_cold;
    u64            nr_failed_migrations_affine;
    u64            nr_failed_migrations_running;
    u64            nr_failed_migrations_hot;
    u64            nr_forced_migrations;
    u64            nr_forced2_migrations;
 
    u64            nr_wakeups;
    u64            nr_wakeups_sync;
    u64            nr_wakeups_migrate;
    u64            nr_wakeups_local;
    u64            nr_wakeups_remote;
    u64            nr_wakeups_affine;
    u64            nr_wakeups_affine_attempts;
    u64            nr_wakeups_passive;
    u64            nr_wakeups_idle;
#endif 
 
#ifdef CONFIG_FAIR_GROUP_SCHED
    struct sched_entity    *parent;
    /* rq on which this entity is (to be) queued: */ 
    struct cfs_rq        *cfs_rq;
    /* rq "owned" by this entity/group: */ 
    struct cfs_rq        *my_q;
#endif 
};
 

阅读(1969) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~