Looking at select, a problem or functionality?

From: George Anzinger (george@pioneer.net)
Date: Mon Jul 17 2000 - 10:21:13 EST


In looking over the kernel for preemption hazards I found the following:

The following function is from select.c. Can someone help me to
understand why do_pollfd() is being called with the task state set to
TASK_INTERRUPTIBLE? do_pollfd() calls the driver poll routine. Is it
expected that the driver might in some way call schedule() and put the
current task to sleep? Or would this be a big NO-NO. I think the state
should be set just prior to the schedule_timeout() call. Would this
impair some functionality? The reason I am asking is, if the kernel is
preempted between the two lines in question, the it appears that the
task will be put to sleep, _forever_! And yes I know the kernel is not
preemptable..._yet_.

If I am correct, then moving the line would also eliminate the need to
set the state back to TASK_RUNNING.

George

static int do_poll(unsigned int nfds, unsigned int nchunks, unsigned int
nleft,
        struct pollfd *fds[], poll_table *wait, long timeout)
{
        int count = 0;

        for (;;) {
                unsigned int i;

                set_current_state(TASK_INTERRUPTIBLE);
                for (i=0; i < nchunks; i++)
                        do_pollfd(POLLFD_PER_PAGE, fds[i], &wait, &count);
                if (nleft)
                        do_pollfd(nleft, fds[nchunks], &wait, &count);
                wait = NULL;
                if (count || !timeout || signal_pending(current))
                        break;
                timeout = schedule_timeout(timeout);
        }
        current->state = TASK_RUNNING;
        return count;
}

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



This archive was generated by hypermail 2b29 : Sun Jul 23 2000 - 21:00:09 EST