malloc() (which uses brk()) vs mmap()....which is better ...the answer is in memory fragmentation. (brk() will fragment the memory, whereas mmap() will not, but it cannot be allocated in too large a block - tradeoff :-))....read further: http://cboard.cprogramming.com/linux-programming/101090-what-differences-between-brk-mmap.html http://coding.derkeiler.com/Archive/Assembler/alt.lang.asm/2005-06/msg00713.html http://www.linuxjournal.com/article/6390 On Fri, Apr 9, 2010 at 1:31 AM, Himanshu Aggarwal <lkml.himanshu@xxxxxxxxx> wrote: > I have read that mmap/mmap2 system calls are more efficient than a read and > a write system call. I am unable to understand why is this so? > mmap/mmap2 always create a vm_area_struct which is inserted into the > process's userspace region. Given that this is the case, how is mmap/mmap2 > more efficient than the read/write system call? Shouldn't it be less > efficient, because each access to mmapped region might be access this > vm_area_struct mapping? > I have another doubt as well : if mmap/mmap2 are more efficient than a write > call, then why don't all drivers just implement a mmap file operation. Why > do they implement a write file-operation which is supposedly less efficient. > I have found only a few drivers implementing the mmap file operation. Is > there any reason for this? > Also, i found that LDD3 book also gives a very "secondary" treatment to this > topic. Shouldn't mmap be used more extensively in device driver development? > Is there any reason for this? > I hope my doubt will be cleared. Thanks to everyone for their replies and > suggestions. > ~Himanshu Aggarwal -- Regards, Peter Teoh -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ