Re: schedule_timeout( )

Andrea Arcangeli (andrea@suse.de)
Thu, 3 Jun 1999 17:57:40 +0200 (CEST)


On Thu, 3 Jun 1999 vgo@ratio.de wrote:

>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();
[xx]
> del_timer(&timer);
>
> timeout = expire - jiffies;
>
>How can the timer expire, when it is deleted
>immediate after scheduling?

The the timer is there only to wakeup the task. When you reach point [xx]
you are just running so you don't need a wakeup anymore.

Note also that the timer is local in the stack so it must be deleted to
not crash into the timer irq.

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

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

Andrea Arcangeli

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