Re: Exchange Date Userspace<->Kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Three ways I know of are: 1) proc interface 2) software device driver 
3) netlink sockets. I guess most addressed software device driver, using
ioctl. proc interface is easier to write. oh ya, don't forget sysctl
too.

Eugene

<quote sender="Prokopenko, Konstantyn">
> Hi.
> 
> If you have small amount of data and no hard real-time performance needed
> you can use slow copy_to_user/copy_from_user macros.
> The fastest way to share data between user space and several devices is to
> map physical memory
> into kernel and user's virtual spaces. This is a very interesting technique
> allows you to AVOID at least one data copy from user to kernel and back. If
> you are moving large amount of data plus performing DMA to/from your
> device(s) - this is the way.
> Now, there are several options to do that.
> 1. Allocate contiguous physical memory using bootmem_allocator (requires
> your driver to be built-in)
> 2. Allocate contiguous physical memory using mem=XXX parameter to get
> unmanageable chunk of memory.
> 
> 'ioremap' the physical memory into kernel's space and implement 'mmap' to
> map the memory chunk into user virtual space and bingo! - you can access the
> chunk of memory from user and kernel space without extra or no copies at
> all. 
> If you have DMA transactions - the memory is already contiguous. Using
> ioctls, spin-locks or other methods you can synchronize access to this
> shared memory from user applications and kernel methodes and isr.
> 
> Regards,
> Konstantyn.
> 
> 
> -----Original Message-----
> From: Danilo Reinhardt [mailto:Danilo.Reinhardt@de.bosch.com]
> Sent: Monday, April 05, 2004 5:38 AM
> To: kernelnewbies@nl.linux.org
> Subject: Exchange Date Userspace<->Kernel
> 
> 
> Hi,
> 
> I want to develop a driver that exchanges/modifies data between 2
> devices. Now I try to find out whats the best way to do this. 
> 
> I think there are 2 ways to do it, the first by doing all work inside
> the driver, and the secondy by passing the data from the driver to an
> userspace programm which handles and forwards the data to the second
> device. 
> 
> Whats the fastest way to exchange data between the kernel and a
> userspace process and how fast is it?
> 
> And on the other side, whats the best way to exchange data inside the
> kernel between 2 devices (which are handled by the same driver!).
> 
> Thanks for all replies!
> 
> Bye Dan
> 
> 
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 
> 

-- 
Eugene TEO -  <eugeneteo%null!cc!uic!edu> <http://www.anomalistic.org/>
1024D/14A0DDE5 print D851 4574 E357 469C D308  A01E 7321 A38A 14A0 DDE5
main(i) { putchar(182623909 >> (i-1) * 5&31|!!(i<7)<<6) && main(++i); }


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux