Find the answer to your Linux question:
Results 1 to 4 of 4
Hi, I need a shared buffer between user and kernel space. I read that one way is to allocated buffer in kernel and then call mmap from the user space. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2010
    Posts
    9

    Shared buffer between user and kernel space


    Hi,
    I need a shared buffer between user and kernel space. I read that one way is to allocated buffer in kernel and then call mmap from the user space. I searched for an example but couldn't find something useful. If you know, could you please send me any links or sample code that does this.... Thank you...

    Thanks,
    Bala

  2. #2
    Just Joined! Alex_Justes's Avatar
    Join Date
    Apr 2010
    Posts
    11
    I don't think, that kernel allow you to access to kernel-space buffer.

    Maybe this could help:
    create buffer from user-space, then in the kernel use copy_from_user and copy_to_user.

    Maybe another solution:
    use /proc filesystem or pseudodevice (/dev) - it is also buffers.

  3. #3
    Just Joined!
    Join Date
    Jul 2009
    Posts
    49

    Creating a shared memory region...

    Where in the kernel are you sharing this memory?

    If it's in a kernel module then you can search on my name in this forum and you will find at least one example of how I've done this before. Essentially I had a kernel module ethernet driver that I added character driver attributes to and then I could use the mmap() function in user space and in kernel space to setup shared memory. If you are trying to share with the kernel this is the way to go.

    You may have to create a dummy module that does nothing but setup the shared memory area if you are targeting some kernel internal buffer.

    Hope this helps!!

    Cheers!!

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Mar 2010
    Posts
    9
    Hi Bloggins,
    Thank you for your answer. I am trying to create some buffer in kernel and share it with userland code. Actually i am trying to reduce the latency of message transmission in a LAN using a simple protocol than TCP/IP. I wanted to avoid copying of packet data from user to kernel. I searched the forums and looked at your previous posts. I am looking for some sample code to understand the process. If it is possible, could you please share your sample code for this part with me? That will be of great help. Thank you....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •