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

Re: info reg. init_task



On Thu, 8 Mar 2001, Narayana, Venkat A. wrote:

> Hi
> I am trying to use init_task to go thru all the tasks.
> The code is like this:
> for ( next = tsk; next != NULL ;next = next->next_task )
> This guys goes into forever loop.What mistake i am doing here?
> Can i use init_task for this?

I haven't looked at this for a few months, but IIRC this is a circular
list.

Try using:
 for (next = tsk->next; next != tsk; next = next->next_task)

(this actually has a bug if there's only 1 process, but that's not going
to be a problem  :-)


Or if you'd rather start at tsk:
 next = tsk;
 do {
   /* ... */
 } while ((next = next->next_task) != tsk);



Regards,
Paul Gearon
pag@PISoftware.com

Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum
immane mittam.
(Translation from latin: "I have a catapult. Give me all the money,
or I will fling an enormous rock at your head.")


-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.surriel.com/kernelnewbies.shtml