Re: [take25 1/6] kevent: Description.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Evgeniy Polyakov wrote:
+ int kevent_wait(int ctl_fd, unsigned int num, __u64 timeout);
+
+ctl_fd - file descriptor referring to the kevent queue +num - number of processed kevents +timeout - this timeout specifies number of nanoseconds to wait until there is + free space in kevent queue +
+Return value:
+ number of events copied into ring buffer or negative error value.

This is not quite sufficient. What we also need is a parameter which specifies which ring buffer the code assumes is currently active. This is just like the EWOULDBLOCK error in the futex. I.e., the kernel doesn't move the thread on the wait list if the index has changed. Otherwise asynchronous ring buffer filling is impossible. Assume this

    thread                             kernel

    get current ring buffer idx

    front and tail pointer the same

                                       add new entry to ring buffer

                                       bump front pointer

    call kevent_wait()


With the interface above this leads to a deadlock. The kernel delivered the event and is done with it.

If the kevent_wait() syscall gets an additional parameter which specifies the expected front pointer the kernel wouldn't put the thread to sleep since, in this case, the front pointer changed since last checked.

The kernel cannot and should not check the ring buffer is empty. Userlevel should maintain the tail pointer all by itself. And even if the tail pointer is available to the kernel, the program might want to handle the queued events differently.

The above also comes to bear without asynchronous queuing if a thread waits for more than one event and it is possible to handle both events concurrently in two threads.

Passing in the expected front pointer value is flexible and efficient.

--
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux