Re: prev->has_cpu

Linus Torvalds (torvalds@transmeta.com)
Fri, 13 Nov 1998 15:12:54 -0800 (PST)


On Fri, 13 Nov 1998, Andrea Arcangeli wrote:
>
> >one. That always works - even if next == prev, in which case it doesn't
>
> If next == prev we don' t switch_to() another task. But the other task
> (not going to be scheduled yet) will just have next->has_cpu == 1 even if
> will not run soon. I think _only_ running (currents) tasks should have
> ->has_cpu == 1.

If "next == prev", then there _is_ no other task.

> >actually do anything. I don't see the problem: schedule() is always
> >guaranteed to be entered with "current->has_cpu == 1" (because otherwise
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Where? I can' t find such piece of code. I think instead that if `prev ==
> next', we' ll exit from the scheule() without changing the current process
> and with current->has_cpu == 0.

No, "current->has_cpu" is _always_ 1 (except inside the scheduler itself,
when it can temporarily drop down to zero while we hold the scheduler
lock). The only case "next == prev" happens is when "current == next ==
prev".

"has_cpu" essentially means that it is actually physcially running on some
CPU.

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/