Pick a Free OS

User login

Navigation

For Kernel_Newbies By a Kernel_Newbie

tasklet_hi_action. But because the old ones are limited in number (32),execute

only one function,and run with spinlock held (they cannot block),task_queues

were introduced which are extended bottom halves. To understand and to use

task_queues,you should look at tqueue.h for its usage. You can do for example:

DECLARE_TASK_QUEUE(run_queue); static struct tq_struct tq; tq->routine =

your_routine; tq->data = &your_data; And then do:

queue_task(&tq,&run_queue); run_task_queue(&run_queue) for it to be

consumed. If you use pre-defined task_queues like ,tq_immediate,tq_timer, then

the task_queue would be consumed at definite points. tq_immediate queue is a

bottom half,and be can run immediately on ret_from_exception/intr by

queue_task(&tq,&tq_immediate); mark_bh(IMMEDIATE_BH). The tq_timer would

be consumed on a timer interrupt (and also on a console_close),So you do for

example: queue_task(&tq,&tq_timer); mark_bh(TIMER_BH). For the

rest,softirq.c should deliver the coup-de-grace on this Section.

The Scheduler :

This section again is covered up beautifully in Linux 2.4 Internals,and

Lazy(const char *lazy,...) can look at Tigrans Materials, or the mor e active

ones, can take up sched.c. The code is actually not that complex, in UNP

mode,but gets solid in SMP mode. The gotos rule the roost in schedule,and one

will start dancing while analysing the code,because its stuffed with \"goto XX,

and goto XX_back.\" They are with a purpose and defy the normal \'C\' guides which

say, \"GOTOs are obsolete and should not be used.\" gotos result in better

assembly code,and the scheduler is one such optimised example. These are the

actions performed by the scheduler in a nutshell:

  • Saving the last process pointer and the processor.
  • handle_softirq back and forth dancing.
  • If the scheduled out tasks policy is Round Robin (SCHED_RR), rr_back and

    forth dancing.

  • Set the next task and goodness value computed by the goodness function to

    that of the idle_tasks.

  • If the scheduled out task is still running (TASK_RUNNING),then

    still_running back and forth dancing,which sets the goodness and next task to

    that of the scheduled out task.

  • If the state of the task is TASK_INTERRUPTIBLE,set it to TASK_RUNNING,and

    if not TASK_RUNNING,delete it from runqueue. (runqueue_head).