2001-10-03 08:26:12

by M.Gopi Krishna

[permalink] [raw]
Subject: wait_event() :(

I have a doubt regarding wait_event.
In the macro __wait_event, the calling process changes its state to
TASK_UNINTERRUPTIBLE and calls schedule.
And does this in infinite loop.
After the loop, it itself changes its state to TASK_RUNNING.

Once it calls schedule(), the scheduler will remove it from task list as
it is in uninterruptible mode.
Then when does it come again into running state to check the condition.

kindly cc the reply to me as i'm not subscribed to the list
thanks

--
gopi.


2001-10-03 09:06:51

by Jan Hudec

[permalink] [raw]
Subject: Re: wait_event() :(

> I have a doubt regarding wait_event.
> In the macro __wait_event, the calling process changes its state to
> TASK_UNINTERRUPTIBLE and calls schedule.
> And does this in infinite loop.
> After the loop, it itself changes its state to TASK_RUNNING.
>
> Once it calls schedule(), the scheduler will remove it from task list as
> it is in uninterruptible mode.
> Then when does it come again into running state to check the condition.
>
> kindly cc the reply to me as i'm not subscribed to the list
> thanks

It inserts itself in a wait queue. The schedule returns when wakeup is called
on the wait queue.

--------------------------------------------------------------------------------
- Jan Hudec `Bulb' <[email protected]>

2001-10-03 09:09:01

by M.Gopi Krishna

[permalink] [raw]
Subject: Re: wait_event() :(

On Wed, 3 Oct 2001, Jan Hudec wrote:

> > I have a doubt regarding wait_event.
> > In the macro __wait_event, the calling process changes its state to
> > TASK_UNINTERRUPTIBLE and calls schedule.
> > And does this in infinite loop.
> > After the loop, it itself changes its state to TASK_RUNNING.
> >
> > Once it calls schedule(), the scheduler will remove it from task list as
> > it is in uninterruptible mode.
> > Then when does it come again into running state to check the condition.
> >
> > kindly cc the reply to me as i'm not subscribed to the list
> > thanks
>
> It inserts itself in a wait queue. The schedule returns when wakeup is called
> on the wait queue.
>
> --------------------------------------------------------------------------------
> - Jan Hudec `Bulb' <[email protected]>
>

Then why does it have a for(;;) around it when anyway someone is going to
wake it up after the condition is true.
Or is that it may be woken up even when the condition is not true.
--
gopi.

2001-10-03 13:11:28

by Jan Hudec

[permalink] [raw]
Subject: Re: wait_event() :(

> > It inserts itself in a wait queue. The schedule returns when wakeup is called
> > on the wait queue.

You may have processes waiting for different events on a single wait queue.
Calling wakeup wakes them up all. Eg. you may have 1 queue per object and
all events wake it up.

--------------------------------------------------------------------------------
- Jan Hudec `Bulb' <[email protected]>