lkml.org 
[lkml]   [2006]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [take25 1/6] kevent: Description.
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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-11-23 00:53    [W:0.089 / U:12.532 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site