主要路径:
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)
阅读(813) | 评论(0) | 转发(0) |