Re: schedule_timeout( )

Riley Williams (rhw@MemAlpha.CX)
Thu, 3 Jun 1999 16:53:48 +0100 (GMT)


Hi Vasili.

> the function schedule_timeout in sched.c does the following:

> expire = timeout + j

> init_timer(&timer);
> timer.expires = expire;
> timer.data = (unsigned long) current;
> timer.function = process_timeout;

> add_timer(&timer);
> schedule();
> del_timer(&timer);

> timeout = expire - jiffies;

> How can the timer expire, when it is deleted immediate after
> scheduling?

It doesn't have to. Remember, the call to schedule() normally results
in the current process sleeping and another process being run. In this
case, what the code says is "Sleep, but wake up no later than when the
specified timer alert occurs".

> Is there an other way to set a process sleep like the one in
> version 2.0.x

> current->timeout = jiffies + t;
> current->state = TASK_INTERRUPTIBLE;
> schedule();
> current->timeout = 0;

How about the following:

current->state = TASK_INTERRUPTABLE;
schedule_timeout(t);

That should do exactly the same as your excerpt...

Best wishes from Riley.

+----------------------------------------------------------------------+
| There is something frustrating about the quality and speed of Linux |
| development, ie., the quality is too high and the speed is too high, |
| in other words, I can implement this XXXX feature, but I bet someone |
| else has already done so and is just about to release their patch. |
+----------------------------------------------------------------------+
* ftp://ftp.MemAlpha.cx/pub/rhw/Linux
* http://www.MemAlpha.cx/kernel.versions.html

-
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/