Moving an application from User Space to Kernel Space - Embedded

This is a discussion on Moving an application from User Space to Kernel Space - Embedded ; 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 Thread
Results 1 to 9 of 9

Thread: Moving an application from User Space to Kernel Space

  1. 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


  2. Re: Moving an application from User Space to Kernel Space

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


    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

  3. Re: Moving an application from User Space to Kernel Space

    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:
    > > I would like to move an application that is currently running in User
    > > Space to Kernel Space.
    > > Need your ideas regarding it.
    > >

    >
    > 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



  4. Re: Moving an application from User Space to Kernel Space

    On 5 Nov 2006 20:46:58 -0800, "karthikbg"
    wrote:

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


    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


  5. Re: Moving an application from User Space to Kernel Space

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


    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

  6. Re: Moving an application from User Space to Kernel Space

    Michael Schnell wrote:
    > karthikbg wrote:
    > > I have written a bit big Flash Drive Furnctionality in the userspace.
    > > Now, Would like to move into the Kernel Space.

    >
    > 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


    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


  7. Re: Moving an application from User Space to Kernel Space

    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 www.yl.is.s.u-tokyo.ac.jp/~tosh/kml.

    Regards,
    Karthik Balaguru


  8. Re: Moving an application from User Space to Kernel Space

    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

  9. Re: Moving an application from User Space to Kernel Space

    karthikbg wrote:

    > It is a Flash Memory driver with lot of userspace interactions which i
    > have been using completely from userspace till now.


    Sounds like you've reinvented the wheel.

    http://www.linux-mtd.infradead.org/

+ Reply to Thread