2009年12月12日 星期六

Kernel scheduling

  • Schedule
You can relinguish your control of CPU. Scheduler will run another task.

REF: schedule()
  • Wait queue
When you can't satisfy user request, put them in wait queue. It's like a I/O wait queue in OS text book.

REF: init_wait_queue_head(), interruptible_sleep_on(), wake_up()

Note: You can also put yourself in the wait queue (when waiting for I/O) by manually:

DECLARE_WAIT_QUEUE(wait, current);
add_wait_queue(wait_q_head, &wait);
while(!condition){
    set_current_state(TASK_INERRUPTIBLE);
    schedule();
}
set_current_state(TASK_RUNNING);
remove_wait_queue(q, &wait);
  • Kernel timer
You can trigger an kernel timer for a delay execution.

REF: init_timer(), del_timer(), add_timer()
  • Task queue
You can use task queue for a delay execution. Very similar to kernel timer. Kernel maintain three pre-defined task queue: scheduler queue, tq_timer, tq_immediate

REF: INIT_TQUEUE(),queue_task(), schedule_task(), DECLARE_TASK_QUEUE(), run_task_queue()

  • Tasklet
You can use a tasklet to schedule a interrupt work in bottom half. It is build on top of softirq

REF: DECLARE_TASKLET(), tasklet_init(), tasklet_schdule()

沒有留言:

張貼留言