Re: schedule_timeout()

Andrew Morton (akpm@zip.com.au)
Tue, 20 Aug 2002 11:40:20 -0700


Lahti Oy wrote:
>
> Why does schedule_timeout() take a signed long as an argument and then check
> for possible negative values? Wouldn't it be better to just take an unsigned
> long as argument, thus eliminating all dumb checks in the code?

Because someone may do:

schedule_timeout(when_i_want_to_wake - jiffies);

and if the current time happens to be _after_ when_i_want_to_wake,
we want schedule_timeout to cope with that and do the right thing.

> Another issue I found concerns setting current task state to TASK_RUNNING
> after calling schedule_timeout(). This seems to be done in many parts of the
> kernel, though Kernel-API documentations found from kernelnewbies.org seem
> to claim that task state is guaranteed to be TASK_RUNNING after
> schedule_timeout() returns. Is the documentation faulty or does the kernel
> have obsoleted code?

The documentation is correct.
-
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/