On Fri, 4 Apr 2008, Nikhil Talpallikar wrote: > On Fri, Apr 4, 2008 at 10:23 PM, Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> > wrote: > > > > > i'm still a bit unclear on the linked list traversal of kernel > > "tasks", given what i'm reading in some documentation someone sent me, > > and i'm thinking that this doc isn't quite correct. > > > > the bullet points in this doc (whose identity shall remain > > concealed, to protect the innocent :-): > > > > * Only default threads linked by tasks list_head > > * Other threads not seen by for_each_process() macro > > * Visible to do_each_thread() macro > > > > now, if by "default thread" the author means the thread group > > leader, this doesn't seem right, does it? that clearly suggests that > > only each thread group leader is on the system-wide task list. i > > thought someone on this (mailing) list had already taken the position > > that, no, *all* threads need to be on the system-wide task list for > > proper scheduling. > > > > and it gets more confusing if you examine the definition of those > > macros in sched.h: > > > > ==================== > > #define next_task(p) \ > > list_entry(rcu_dereference((p)->tasks.next), struct task_struct, > > tasks) > > > > #define for_each_process(p) \ > > for (p = &init_task ; (p = next_task(p)) != &init_task ; ) > > > > /* > > * Careful: do_each_thread/while_each_thread is a double loop so > > * 'break' will not work as expected - use goto instead. > > */ > > #define do_each_thread(g, t) \ > > for (g = t = &init_task ; (g = t = next_task(g)) != &init_task ; ) > > do > > > this is a double loop > > #define while_each_thread(g,t) \ > while ((t = next_thread(t) != g) > > this leads to the conclusion.....the document ur reading document is > correct. ah, i get it -- i didn't look closely enough at the actual *invocation* of those macros -- you're supposed to use do_each_thread() and while_each_thread() in pairs on a single loop, as in: do_each_thread(g, p) { /* * reset the NMI-timeout, listing all files on a slow * console might take alot of time: */ touch_nmi_watchdog(); if (!state_filter || (p->state & state_filter)) sched_show_task(p); } while_each_thread(g, p); my fault, sorry for the noise. must read more carefully next time. rday -- ======================================================================== Robert P. J. Day Linux Consulting, Training and Annoying Kernel Pedantry: Have classroom, will lecture. http://crashcourse.ca Waterloo, Ontario, CANADA ======================================================================== -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ