Date: Wed, 11 Apr 2001 09:52:33 +1000 From: Peter Jeremy <peter.jeremy@alcatel.com.au> To: freebsd-arch@freebsd.org Subject: mmap(2) vs read(2)/write(2) Message-ID: <20010411095233.P66243@gsmx07.alcatel.com.au>
next in thread | raw e-mail | index | archive | help
It is my understanding that it is more efficient to access a file via mmap rather than read/write, because the former needs one less memory-memory copy. Currently stdio uses read/write, but it would seem trivial to change at least the read operations to use mmap. For an mmap'd file, FILE->_p would point to the mmap'd region and FILE->_r would represent the number of remaining valid bytes. FILE->_bf could be used to cache the mmap'd region. My reading of ISO-C is that the mode argument to fopen(3) can include arbitrary, implementation-defined enhancements - which would allow an application to select read/write or mmap and maybe allow the application to advise its intended behaviour (ala madvise(2)). The behaviour of `portable' applications could be controlled via /etc/stdio.conf and STDIO_CONF in the same manner as malloc(3). Does this sound like a worthwhile enhancement? Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010411095233.P66243>