lkml.org 
[lkml]   [1999]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Calling userspace function from inside kernel (still) possible?
From
Date
Arjan Opmeer <a.d.opmeer@student.utwente.nl> writes:

> Hi all,
>
> I am wondering whether it is possible to call a userspace routine from
> within the kernel, say a module or something.
> The Linux Kernel Hacker Guide states as one solution to call kerneld from
> kernel mode and have it execute a seperate program.
> Since kerneld had been replaced with kmod, and the kmod documentation
> states it can only be used to load modules on demand this solution clearly
> is not an option anymore.
>
> ( Little background info: I am thinking about an extension to the kernel via
> a kernel module. Userspace processes can register themselves with that
> module and be called whenever some condition in the kernel is met. When
> someone has another idea about how to handle this situation I would
> certainly like to hear it. )

Calling userspace function from inside kernel (still) possible?

Yes it is.

I wrote a small generic module that sends a SIGCONT signal to a
registered user space process upon an event in the Kernel. The user
space program has to open the /dev/my_generic_module entry point and
provide it its pid number through an ioctl call. Then, the user space
program needs an handler for the SIGCONT (or whatever signal) and goes
into pause() and waits for a signal. Upon a given event in the
Kernel. the module sends a signal to the process with kill_proc(pid,
signal, 0).

In my case, the Kernel event is simply a function of my module being
scheduled every jiffy. This way of doing is fairly simple and you
don't have to play with any other parts of the Kernel. There are
probably other ways (and probably better) of doing this, but this
works well.


Claude

--
Claude Gamache, CAE Electronique Ltee, 8585 Cote-de-Liesse
Saint-Laurent, Quebec, Canada H4T 1G6
Email: cgamache@cae.ca Tel.: (514) 341-2000 x3194, Fax: (514) 734-5612

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:50    [W:0.072 / U:0.464 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site