On Tue, Jul 12, 2011 at 9:56 AM, Amit Nagal <helloin.amit@xxxxxxxxx> wrote: > On Tue, Jul 12, 2011 at 11:51 AM, Tirtha Ghosh <gtirtha@xxxxxxxxx> wrote: >> Use a shared memory between user space and kernel space. >> The same physical memory can be translated as user-space virtual address as >> well as kernel space. >> See more about mmap, io_remap_pfn_range etc. and you will get an idea. >> The main advantage with this u can avoid copying data between two spaces but >> disadvantage associated is u need to request a fixed memory chunk from >> kernel for this purpose. >> >> > Thanx for reply . Regarding mmap usage , As per LDD3 , page 423 : > "Not every device lends itself to the mmap abstraction; it makes no > sense, for instance, for serial ports and other stream-oriented > devices." . > > why mmap is not useful for stream-oriented devices ? > After all even for stream-oriented device (as in my case ) , we need > to copy data from kernel buffer to user-space buffer , > and if copy can be avoided via any mechanism , it will be much faster . Usually, character oriented devices, are only aware of 'next byte' to send/receive. Think what would happen, if you map a memory area of 4K, but only 1 byte has arrived? You would need to find a way to tell user, that mmapped area is not yet ready to be read, or only the first byte is valid. Also, think if lseek makes sense on a serial device. thanks, Daniel. _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies