RE: Processor descriptor

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

 



To get information about the currently running task we use:

current_task_info()->task

this looks up the Structure thread_info from where another Structure task_info is looked up

Maybe I am knive, I dont understand the C syntax, is current_task_info() a function.  Please explain the syntax in detail.

Best
A.S.
Hi,
 
the function current_thread_info is given as follows in asm/thread_info.h
 
static inline struct thread_info *current_thread_info(void)
{
    struct thread_info *ti;
    __asm__("andl %%esp, %0; ":"=r" (ti) : "0" (~8191UL));
    return ti;
}
 
The important thing to note is that it is protptyped to return a struct thread_info * (a thread_info pointer).
 
In C when you say current_thread_info()->task, the current_thread_info() part of the _expression_ evaluates to what is returned when this function is called (in this case a thread_info pointer). You can then access the task field in this struct.
 
Thus
 
struct task_struct *task = current_thread_info()->task
 
is essentially equivalent to
 
struct thread_info *ti;
 
ti = current_thread_info();
struct task_struct *task = ti->task;
 
Hope this helps.
Yagnavarahan

[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