tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Interface for communicating from kernel to user mode
> what is suitable interface or mechanism on NetBSD to send message
> with some data from kernel-mode code to user-mode process ?
There are lots of options. Depending on tradeoffs such as the typical
size of a message, the bandwidth required, and how many such comm
channels need to be supported at once, some options may be more
attractive than others.
> For example in the past on Linux I used on call nlmsg_unicast(socket,
> buffer, pid) to send data to some user-mode process.
I have no idea what nlmsg_unicast does beyond Eliza-effect inferences
from the names you used, so that's not a useful example for me. (I'm
sure there are people here who also hack Linux kernel code and thus
will know exactly what it means.)
I've used various interfaces over the years.
- A dedicated custom pseudo-device driver which userland can read from
and/or write to to transfer data out of and into the kernel.
- A dedicated custom syscall (which, of course, can do whatever it
wants).
- Userland creates an AF_LOCAL SOCK_STREAM socketpair and passes one of
the resulting socket fds to the kernel, which takes over the
referenced socket and uses it, with userland reading from and
writing to the other socket.
- The kernel drops memory into the process's VM space, then notifies
userland of the new VM's location and size using socket ancillary
data, sibling to SCM_RIGHTS.
- The kernel records the data in kernel-internal storage; userland uses
/dev/kmem to fetch it. (This one is unidirectional; I don't think
I've ever quite dared to use /dev/kmem to write into the kernel for
anything but debugging hackery.)
I'm sure there are plenty of other possibilities. These are just the
ones I offhand recall using.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Home |
Main Index |
Thread Index |
Old Index