Alex Rivera | Logout

What is the ideal & fastest way to communicate between kernel and user space?

Asked 2009-06-02T22:36:05.073
10

I know that information exchange can happen via following interfaces between kernel and user space programs

  • system calls

  • ioctls

  • /proc & /sys

  • netlink

I want to find out

  • If I have missed any other interface?

  • Which one of them is the fastest way to exchange large amounts of data? (and if there is any document/mail/explanation supporting such a claim that I can refer to)

  • Which one is the recommended way to communicate? (I think its netlink, but still would love to hear opinions)

Edit
Report

1 Answer

7

The fastest way to exchange vast amount of data is memory mapping. The mmap call can be used on a device file, and the corresponding kernel driver can then decide to map kernel memory to user address space. A good example of this is the Video For Linux drivers, and I suppose the frame buffer driver works the same way. For an good explanation of how the V4L2 driver works, you have :

You can't beat memory mapping for large amount of data, because there is no memcopy like operation involved, the physical underlying memory is effectively shared between kernel and userspace. Of course, like in all shared memory mechanism, you have to provide some synchronisation so that kernel and userspace don't think they have ownership at the same time.

answered 2009-06-03T07:43:26.200

Your Answer