Re: list_head and struct_task

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 30 December 2008 23:25:39 Shyam Burkule wrote:
> Hi All,

Hi!

>       Linux kernel make use list_head to link process descriptor. I am
> reading scheduler part of Linux kernel. There is structure *runqueue* that
> contains list of all runnable process. The *runqueue* has pointer to
> *prio_array_t* structre that have field *queue*(array of struct
> prio_array_t) which list process according to priority. The scheduler gets
> head_list from this queue.

First, which version of the kernel are you working with? From what you ask, it 
sounds like you are working with the O(1) scheduler setup.

as Peter said, there's a individual instance of the runqueue, (kernel/sched.c 
struct rq). In this rq, you will find a cfs_rq struct (the runqueue for 
normal tasks) as well as a rt_rq struct. In these runqueues are the tasks 
runnable on a given CPU.

The only place you will find prio_array, will be in the rt_rq runqueue, which 
has been renamed to rt_prio_array (as normal tasks do not use prio-array but 
red-black trees nowadays).

> I did not understand how scheduler gets process desciptor address
> corrosponding to list_head, which it (scheduler) gets from runqueue list??
> Please point me to code gthat does this translation.

you have a macro, called this_cpu() that will return the current cpu. With 
this, you can retrieve the correct runqueue, and from that, you can find the 
given runqueues for normal- and rt-tasks via the macro cpu_rq(cpu)

so, a struct rq *r = cpu_rq(this_cpu()); would probably do the trick. You also 
have the smp_processor_id() wich returns the id of the processor

I think the answer to your question, is that the kernel first retrieves the 
appropriate CPU, then finds the runqueue for this CPU, and from the runqueue, 
find the currently executing task, as well as actual queues with tasks.

Let me know if I misunderstood your question! :-)

> Thanks
>      Shyam

-- 
 -> henrik

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux