Chinaunix首页 | 论坛 | 博客
  • 博客访问: 649875
  • 博文数量: 156
  • 博客积分: 4833
  • 博客等级: 上校
  • 技术积分: 1554
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-21 19:36
文章分类

全部博文(156)

文章存档

2016年(2)

2013年(1)

2012年(13)

2011年(30)

2010年(46)

2009年(29)

2008年(23)

2007年(12)

分类: BSD

2011-12-18 12:59:29

主要路径:

sched_bind=>
       ts->ts_cpu = cpu
mi_switch(SW_VOL, NULL)=>主动放弃运行

sched_switch=>

        sched_switch_migrate
()
         cpu_switch()


Linux:

    sched_setaffinity=>cpuset_cpus_allowed
                     =>set_cpus_allowed_ptr=>migrate_task
 /*
 * This is how migration works:
 *
 * 1) we queue a struct migration_req structure in the source CPU's
 *    runqueue and wake up that CPU's migration thread.
 * 2) we down() the locked semaphore => thread blocks.
 * 3) migration thread wakes up (implicitly it forces the migrated
 *    thread off the CPU)
 * 4) it gets the migration request and checks whether the migrated
 *    task is still in the wrong runqueue.
 * 5) if it's in the wrong runqueue then the migration thread removes
 *    it and puts it into the right queue.
 * 6) migration thread up()s the semaphore.
 * 7) we wake up and the migration is done.
 */

     code:
     if (migrate_task(p, any_online_cpu(*new_mask), &req)) {
        /* Need help from migration thread: drop lock and wait. */
        task_rq_unlock(rq, &flags);
        wake_up_process(rq->migration_thread);
        wait_for_completion(&req.done);
        tlb_migrate_finish(p->mm);
        return 0;

 /*
 * migration_thread - this is a highprio system thread that performs
 * thread migration by bumping thread off CPU then 'pushing' onto
 * another runqueue.
 */

static int migration_thread(void *data)
=>static int __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu)
阅读(778) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~