Hi Kim,
On 11/06/2014 05:19 AM, Kim Bøndergaard wrote:
> In agreement with Tobias I'll try to implement a kernel module providing
> ach channels as character devices.
Great!
> Basically I'll follow Neil's suggestion with one device (say
> /dev/achctrl) to be used for creating the actual channel devices.
>
> My idea is to extend the ach create attributes with a flag, say
> map_kernel telling the ach library to create the new channel as a
> kernel channel
Sounds good. I think it would be best to have a combined namespace
for user/kernel space channels -- so users can't create channels with
the same name in both user and kernel space, and ach_open() will open
from whichever space happens to exist.
> The flag map_kernel and map_anon are of course mutual exclusive, and I
> surely would have preferred e.g. an enum, but due to backward
> compatibility...)
Here's an option to mostly preserve compatibility:
* Replace the map_anon field with:
union { int map_anon; int map };
* Add:
enum ACH_MAP_SPACE
{
ACH_MAP_USER=0;
ACH_MAP_ANON=1;
ACH_MAP_KERNEL=2;
}
> I.e. from an apps point of view creation of the channels remains almost
> as it is today.
>
> When it comes to the other ach_ functions the api will remain the same.
Sounds good. Might make sense to implement the userpace/kernelspace
functions using a vtable?
> The use case bringing up this issue was a need to listen on more
> channels at once from within one thread.
> To support this feature a foresee a new function, say ach_get_fd(), able
> to handout the file descriptor behind a (kernel) ach_handle.
There is already an fd field in ach_channel_t, but might be better to
create the separate accessor function.
> In order for the file descriptor to become 'ready' as expected when
> calling select() we'll probably need IOCTL means to set the right
> options before calling select() (probably ACH_O_WAIT)
> When select() returns the app can use the existing ach_get() (probably
> with option ACH_O_LAST) to fetch the data.
I'd suggest doing this transparently as follows:
* Keep a field in userspace that tracks the kernel space flags set by
ioctl()
* When ach_get() is called, if the flags are different from what was
previously set, call the appropriate ioctl()
Cheers,
-ntd