2003-08-21 14:44:17

by Pankaj Garg

[permalink] [raw]
Subject: Messaging between kernel modules and User Apps

Hi,

I am writing a kernel module. The module will need to send asynchronous
messages to a User Application. Is there a good and efficient way of
doing this?


Thanks,
Pankaj



2003-08-21 14:55:11

by Pádraig Brady

[permalink] [raw]
Subject: Re: Messaging between kernel modules and User Apps

Pankaj Garg wrote:
> Hi,
>
> I am writing a kernel module. The module will need to send asynchronous
> messages to a User Application. Is there a good and efficient way of
> doing this?

netlink socket?

P?draig.

Subject: RE: Messaging between kernel modules and User Apps

> I am writing a kernel module. The module will need to send asynchronous
> messages to a User Application. Is there a good and efficient way of
> doing this?

Let user space read the data from a device file.
Use poll/select to handle the asynchronous notification.

The other option is to have the driver send a signal to user space.
I've done that before, but at best it's a hack and not neatly supported
by the Linux driver model.


2003-08-21 15:14:36

by Richard B. Johnson

[permalink] [raw]
Subject: Re: Messaging between kernel modules and User Apps

On Thu, 21 Aug 2003, Pankaj Garg wrote:

> Hi,
>
> I am writing a kernel module. The module will need to send asynchronous
> messages to a User Application. Is there a good and efficient way of
> doing this?
>
>
> Thanks,
> Pankaj
>
The de facto standard for network devices is to use sockets.
For character and and block devices Unix/Linux uses the
open/poll/ioctl/read mechanisms.
Some Linux drivers use the /proc file-system for 'information'.
You could send your module a pid via proc and have it send a
signal to your application as a result of an event.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.


2003-08-21 16:26:48

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: Messaging between kernel modules and User Apps

On Thu, 21 Aug 2003, Richard B. Johnson wrote:

> The de facto standard for network devices is to use sockets.
> For character and and block devices Unix/Linux uses the
> open/poll/ioctl/read mechanisms.

That sounds fine, but..

> You could send your module a pid via proc and have it send a
> signal to your application as a result of an event.

... please don't even entertain such sick ideas.

2003-08-21 16:56:04

by Ihar 'Philips' Filipau

[permalink] [raw]
Subject: Re: Messaging between kernel modules and User Apps

Zwane Mwaikambo wrote:
>>The de facto standard for network devices is to use sockets.
>>For character and and block devices Unix/Linux uses the
>>open/poll/ioctl/read mechanisms.
>
> That sounds fine, but..
>
>>You could send your module a pid via proc and have it send a
>>signal to your application as a result of an event.
>
> ... please don't even entertain such sick ideas.

Especially when there is fcntl(F_{G,S}ET{OWN,SIG}) infrastructure in
place - kill_fasync().

2003-08-21 17:23:06

by Richard B. Johnson

[permalink] [raw]
Subject: Re: Messaging between kernel modules and User Apps

On Thu, 21 Aug 2003, Ihar 'Philips' Filipau wrote:

> Zwane Mwaikambo wrote:
> >>The de facto standard for network devices is to use sockets.
> >>For character and and block devices Unix/Linux uses the
> >>open/poll/ioctl/read mechanisms.
> >
> > That sounds fine, but..
> >
> >>You could send your module a pid via proc and have it send a
> >>signal to your application as a result of an event.
> >
> > ... please don't even entertain such sick ideas.
>
> Especially when there is fcntl(F_{G,S}ET{OWN,SIG}) infrastructure in
> place - kill_fasync().
>

Just getting 'even' for the last time I advised poll()/ioctl() and
I was pummeled with "No... use /proc"! Of course the "best" method
is to open a file in the kernel module and have the user poll for
a change in length ->;^;<-)

Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.