Re: Use of yield() in the kernel

Pavel Machek (pavel@ucw.cz)
Sun, 20 Oct 2002 00:00:00 +0200


Hi!

> > > Here is the list of files using yield(), excluding non-i386 arch specific
> > > files:
> >
> > ...
> >
> > > kernel/suspend.c
> >
> > This is okay.
>
> Hi Pavel, I agree. I have some questions about the code though:
> when you come across a thread with (p->flags & PF_FROZEN), why
> break out of the loop? Why not just skip this thread and go on to
> the

There's "continue;" in there, and it should "just skip this thread".
Pavel

> next one? Also, does it matter if the code doing the freezing is itself
> frozen?
>
> Ciao, Duncan.
>
> PS: Here is the code, for reference:
>
> do {
> todo = 0;
> read_lock(&tasklist_lock);
> do_each_thread(g, p) {
> unsigned long flags;
> INTERESTING(p);
> if (p->flags & PF_FROZEN)
> continue;
>
> /* FIXME: smp problem here: we may not access other proc
> ess' flags
> without locking */
> p->flags |= PF_FREEZE;
> spin_lock_irqsave(&p->sig->siglock, flags);
> signal_wake_up(p);
> spin_unlock_irqrestore(&p->sig->siglock, flags);
> todo++;
> } while_each_thread(g, p);
> read_unlock(&tasklist_lock);
> yield();
> if (time_after(jiffies, start_time + TIMEOUT)) {
> printk( "\n" );
> return todo;
> }
> } while(todo);

-- 
Casualities in World Trade Center: ~3k dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/