将list_entry应用于task_struct

时间:2012-03-28 05:46:59

标签: linux kernel

list_for_each(list, &current->children) { 
      task = list_entry(list, struct task_struct, sibling); 
      /* task now points to one of current’s children */
}

根据这个答案:list_entry in Linuxlist_entry()宏将根据指定数据结构中提供的指针(在本例中为list)的偏移量转换为指定的结构(在这种情况下,task_struct)。但是,在上面的代码中,我认为list是指向下一个task_struct的指针,从头开始。为什么代码将list从偏移sibling转发回task_struct,这不是task_struct的开头?或者,list直接指向下一个sibling的{​​{1}}成员?

0 个答案:

没有答案
相关问题