Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Linux kernel modules C and Java
Linux kernel modules C and Java [message #137225] Wed, 02 February 2005 09:14 Go to next message
Eclipse UserFriend
Hi,



On Linux (Intel), is it possible to call Java from a loadable kernel module
written in C? I guess I'm not asking about JVM invocation API or JNI but
whether the environment in which such a module executes (kernel space etc)
makes it possible to use invocation API and JNI.



Thanks/Mikael
Re: Linux kernel modules C and Java [message #137325 is a reply to message #137225] Wed, 02 February 2005 19:32 Go to previous messageGo to next message
Eclipse UserFriend
Mikael Hakman wrote:
> On Linux (Intel), is it possible to call Java from a loadable kernel module
> written in C? I guess I'm not asking about JVM invocation API or JNI but
> whether the environment in which such a module executes (kernel space etc)
> makes it possible to use invocation API and JNI.

Yes, but only if you first solve the problem of running the JVM in
kernel space too. Otherwise, you need to communicate with a user-space
process that does the actual Java method invocation (upcall across the
kernel-user boundary) as a proxy for the kernel. The upcall technique is
popular for signalling management daemons about events that occur in the
kernel. The better examples are the PCMCIA card manager and hotplug
daemons. But I'm not sure I'd use it for invoking Java methods. There
are all kinds of synchronization problems that you create for yourself
to handle, whereas events tend to be one-shot messages.
Re: Linux kernel modules C and Java [message #137370 is a reply to message #137325] Thu, 03 February 2005 04:46 Go to previous messageGo to next message
Eclipse UserFriend
Scott Michel wrote:
> Mikael Hakman wrote:
> > On Linux (Intel), is it possible to call Java from a loadable kernel
module
> > written in C? I guess I'm not asking about JVM invocation API or JNI but
> > whether the environment in which such a module executes (kernel space
etc)
> > makes it possible to use invocation API and JNI.
>
> Yes, but only if you first solve the problem of running the JVM in
> kernel space too. Otherwise, you need to communicate with a user-space
> process that does the actual Java method invocation (upcall across the
> kernel-user boundary) as a proxy for the kernel. The upcall technique is
> popular for signalling management daemons about events that occur in the
> kernel. The better examples are the PCMCIA card manager and hotplug
> daemons. But I'm not sure I'd use it for invoking Java methods. There
> are all kinds of synchronization problems that you create for yourself
> to handle, whereas events tend to be one-shot messages.

Many thanks, Scott!

So, the problem is that JVM does not run in kernel space. Any hope that we
will get such a JVM? Perhaps one of those embedded, micro or nano JVMs?

Another question, AFAIK gcc is able to compile Java into native code (with
some restrictions of what the code can do). Would such a code be usable in
kernel space? Or would run-time library that this code needs be a problem?

Mikael
Re: Linux kernel modules C and Java [message #137475 is a reply to message #137370] Thu, 03 February 2005 17:17 Go to previous message
Eclipse UserFriend
Mikael Hakman wrote:
> Many thanks, Scott!
>
> So, the problem is that JVM does not run in kernel space. Any hope that we
> will get such a JVM? Perhaps one of those embedded, micro or nano JVMs?

Kernel dynamic memory allocation is not the same as user space dynamic
memory allocation; it's a critical piece of code where you don't want
memory fragmentation if you can avoid it. You could port a micro or nano
JVM into the kernel, but you'll have to cope with a lot of manual memory
management (i.e., allocating slabs of memory, doing GC within those
slabs.) It's not like you can just go off and malloc() a few bytes.

Basically, given the pain of the actual undertaking, I really doubt that
anyone except someone who's trying to rack up geek points and no social
life would do it. In other words, it'll probably be done next week by
some really enterprising hacker. But not me, since I think I understand
the complexity of the problem and I have other things to do in life.

> Another question, AFAIK gcc is able to compile Java into native code (with
> some restrictions of what the code can do). Would such a code be usable in
> kernel space? Or would run-time library that this code needs be a problem?

If you look at the compiler's output, it's C++. Can you put C++ into a
mainline Linux kernel? IIRC, there's also the gcj runtime. And then you
have to cope with code that hasn't been compiled and is still JVM byte
codes... taking you back to step one.
Previous Topic:windows xp, cygwin, CDT and me
Next Topic:project dependency and linking
Goto Forum:
  


Current Time: Mon Jul 14 07:47:17 EDT 2025

Powered by FUDForum. Page generated in 0.07136 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top