Re: Send data from kernel to userspace with KEXT control ?
Re: Send data from kernel to userspace with KEXT control ?
- Subject: Re: Send data from kernel to userspace with KEXT control ?
- From: NAHieu <email@hidden>
- Date: Sat, 9 Sep 2006 14:30:23 +0900
Hi Josh,
On 9/7/06, Josh Graessley <email@hidden> wrote:
Hello,
ctl_enqueuedata and ctl_enqueuembuf will enqueue data in the receive
queue for you. When you call those functions, your user space process
that is presumably waiting for data, will be woken up, giving it a
chance to call recv to get to that data.
Excellent!!! It is less ambiguity now for me. Could you point me to
any documentation about ctl_enqueudata/clt_enqueuembuf? Is there any
sample code about using kernel control to exchange data between
kernelspace and userspace?
Too bad that the NKE documentation fails to mention these functions?
Many thanks.
H
I believe the point the documentation is making is that there is a
disconnect on the kernel to userspace side. When userspace calls to
the kernel, it all happens on one thread. There is a context switch to
go from userspace to kernel. When the kernel wants to pass data to
user space, it enqueues the data and any thread in userspace gets
kicked so it will call receive.
-josh
On Sep 6, 2006, at 2:25 AM, NAHieu wrote:
> Hi,
>
> I have a kext that has some data to send out to userspace. After some
> time of investigations (great thanks to developers on this ML), I
> think it is a good idea to employ network stack for this job.
>
> To do that, I register a kernel control (ctl_register() function) in
> kernel, and have an application in userspace. The application will
> periodically send request for data to kernel. Inside kernel, I have a
> buffer, and it is necessary to send all the data from the buffer out
> to the userspace application.
>
> However, from the guide "Network kernel extensions programming
> guide", we read :
> " ..... the user process can communicate with the control using
> getsockopt, setsockopt, recv, and send on the socket. With the
> exception of recv (which is transparently handled with a queue), calls
> in user space to these functions result in a kernel-space call to the
> equivalent functions in the control, ctl_getopt_func, ctl_setopt_func,
> and ctl_send, respectively.
> ........"
>
> So it is not clear how we can handle receive function (recv) from
> inside kernel?
> I understand that to send data out (when client requests with recv()),
> I must handle the buffer for recv(), but I dont know how to do that.
> Too bad the documentation is quite ambiguity to me.
>
> Would anybody help me?
>
> Many thanks,
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden