Chinaunix首页 | 论坛 | 博客
  • 博客访问: 353193
  • 博文数量: 197
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 303
  • 用 户 组: 普通用户
  • 注册时间: 2013-09-02 14:21
文章分类

全部博文(197)

文章存档

2014年(89)

2013年(108)

我的朋友

分类: LINUX

2013-11-14 17:59:33

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 
};
 

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