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

Reply via email to