Moving an application from User Space to Kernel Space

Hi,

I would like to move an application that is currently running in User Space to Kernel Space. Need your ideas regarding it.

Regards, Karthik Balaguru

Reply to
karthikbg
Loading thread data ...

1) The Kernel API from Kernel space is completely different from that used by user space. So no chance without rewriting the application. 2) Why would somebody want to do this ? What are you trying to accomplish. Kernel space applications ("modules", "drivers") need to be as small and simple as possible.

-Michael

Reply to
Michael Schnell

I have written a bit big Flash Drive Furnctionality in the userspace. Now, Would like to move into the Kernel Space.

Yes, the Kernel APIs from Kernel Space are completely different.

But, is there any tool that will help in accomplishing task ???

Share your views and suggestions regarding this

Regards, Karthik Balaguru

Michael Schnell wrote:

Reply to
karthikbg

Why ?

You have not given a single justification for moving it.

Are there any critical timing issues that can not be satisfied in user mode ?

Are there multiple processes that will simultaneously access the Flash and you need to coordinate the access ?

Do you want to access the Flash using ordinary fread/fwrite or read/write/select calls ?

In the first case, you should divide the functionality into the time critical low level access and put in the kernel mode and put higher level functions, such as directory handling in user mode.

Whatever you do, at least check the API parameters from kernel mode that the intended access would have been possible from the user mode.

There was once a big OS vendor which decided to move some of the graphical interface from user mode to kernel mode in a new 4.0 OS version to speed up the display update by eliminating a lot mode changes, but "forgot" to check that the parameter could have been accessible from user mode. So if by mistake, you gave a wrong parameter or a NULL pointer to some of these calls, the whole OS crashed :-), while previously in 3.xx OS versions only the offending application terminated.

Paul

Reply to
Paul Keinanen

I don't understand "Flash Drive Functionality".

Is the "Flash Drive" a standard flash card ? So you should use the appropriate driver (e.g. IDE for Compact Flash).

Is the "Flash Drive" a chip in the CPU's address space ? So you should use the standard MTD driver (Maybe you need to modify the MTD driver according to your hardware).

Is it something else ? You might need to create a _small_ kernel mode driver that just moves blocks of data to/from the Flash. (Hardware driver layer)

Is the "Functionality" a kind of file system ? Can't you use an existing file system ? If not, you might write you own Kernel mode file system according to the standards.

Is the "Functionality" something different ? Will it provide functions to be accessed by user mode programs ? You could create a Kernel mode module to provide accessibility using a standard driver API. This driver should use the hardware driver layer by an internal API. Or you could create an "so" library with a propriety API. The "so" will use the hardware driver to access the flash memory.

If not this would be a user mode program using the API of the hardware driver.

Have fun !

-Michael

Reply to
Michael Schnell

Hi , It is a Flash Memory driver with lot of userspace interactions which i have been using completely from userspace till now. Thankyou for all your responses. Your ideas have really given me the necessary clarifications.

Regards, Karthik Balaguru

Reply to
karthikbg

Hi,

I came across something interesting related to this via google. It is KML .

The Interesting thing is bash gets executed from kernel mode :) :) :)

For example, the following commands execute bash in kernel mode.: % cp /bin/bash /trusted/bin && /trusted/bin/bash

KML is a modified Linux kernel that executes user processes in kernel mode, which then are called kernel-mode user processes. Kernel-mode user processes can interact with the kernel directly. Therefore, the overhead of system calls can be eliminated. KML is provided as a patch to the source of the original Linux kernel, so you need to build the kernel from the source.

To use KML, apply the patch and enable Kernel Mode Linux when you configure your kernel. Build and install the kernel, and then reboot. The KML patch is available from

formatting link

Regards, Karthik Balaguru

Reply to
karthikbg

Funny stuff :)

Very interesting, but I don't think it's really recommended to use this, as it asks for a lot of problems that are really fun to debug.

-Michael

Reply to
Michael Schnell

Sounds like you've reinvented the wheel.

formatting link

Reply to
Geronimo W. Christ Esq

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.