Re: select system call's implementation may have some bug, needyour help and confirm !!!

From: Peter Zijlstra
Date: Fri Oct 09 2009 - 05:21:59 EST


On Fri, 2009-10-09 at 08:52 +0100, Alan Jenkins wrote:
> On 10/9/09, wu Jianfeng <stormplayer@xxxxxxxxx> wrote:
> > A process may sleep for ever when he call select system call.
> > In detail, if the process was scheduled out just at the point it set
> > its state to TASK_INTERRUPTIBLE.
> >

> > set_current_state(TASK_INTERRUPTIBLE);
> > ## here set the process state TASK_INTERRUPTIBLE
> >
> > ## if the process was scheduled out here, then the process will
> > never can be waked up, because it has not been attached to any file 's
> > wait queue.
>
> I'm not sure about that, but if you look at the current code (e.g. in
> linus' git tree) you will see this code has been changed. Now
> set_current_state() is only called from poll_schedule_timeout(), and
> it won't suffer from the problem you suggested:
>
>
> int poll_schedule_timeout(struct poll_wqueues *pwq, int state,
> ktime_t *expires, unsigned long slack)
> {
> int rc = -EINTR;
>
> set_current_state(state);
> if (!pwq->triggered)
> rc = schedule_hrtimeout_range(expires, slack, HRTIMER_MODE_ABS);
> __set_current_state(TASK_RUNNING);

It would still be liable to the problem suggested, if it were real,
which it is not, as Thomas pointed out.

The distinction is between getting preempted and calling schedule().

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/