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

Evgeniy Polyakov
2006-11-23T11:53:57Z

On Wed, Nov 22, 2006 at 03:46:42PM -0800, Ulrich Drepper (drepper@redhat.com) wrote:
> 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.

Kernel does not put there a new entry, it is only done inside
kevent_wait(). Entries are put into queue (in any context), where they can be obtained
from only kevent_wait() or kevent_get_events().

--
Evgeniy Polyakov