next_task & current & for_each_process

2019-07-14 12:49发布

next_task宏定义为:
#define next_task(p)    list_entry(rcu_dereference((p)->tasks.next), struct task_struct, tasks) 获取下一个PCB指针
--------------------------------------------------------------------------------------------------------------------------------------- current #define current get_current() #define get_current() (current_thread_info()->task)     static inline struct thread_info *current_thread_info(void) 
   { 
        register unsigned long sp asm ("sp"); 
        return (struct thread_info *)(sp & ~(THREAD_SIZE - 1)); //用于将sp对其到内核栈栈底,即存放thread_info结构的地方,然后转换成
     // thread_info *返回
   }

---------------------------------------------------------------------------------------------------------------------------------------

for_each_process是在linux/sched.h中的宏定义:
#define for_each_process(p) for (p = &init_task ; (p = next_task(p)) != &init_task ; )