[PATCH][RESEND] Fix msleep to sleep _at_least_ the requested amount

Benjamin Herrenschmidt
2004-10-25T00:21:57Z

Hi Linus !

You "agreed" but didn't apply the patch on the last message ... so here
it is again.

Makes sure msleep() sleeps at least the amount provided, since
schedule_timeout() doesn't guarantee a full jiffy.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

===== kernel/timer.c 1.100 vs edited =====
--- 1.100/kernel/timer.c 2004-10-19 19:40:28 +10:00
+++ edited/kernel/timer.c 2004-10-23 09:16:10 +10:00
@@ -1605,7 +1605,7 @@
*/
void msleep(unsigned int msecs)
{
- unsigned long timeout = msecs_to_jiffies(msecs);
+ unsigned long timeout = msecs_to_jiffies(msecs) + 1;

while (timeout) {
set_current_state(TASK_UNINTERRUPTIBLE);
@@ -1621,7 +1621,7 @@
*/
unsigned long msleep_interruptible(unsigned int msecs)
{
- unsigned long timeout = msecs_to_jiffies(msecs);
+ unsigned long timeout = msecs_to_jiffies(msecs) + 1;

while (timeout && !signal_pending(current)) {
set_current_state(TASK_INTERRUPTIBLE);