Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcnc!rti!xyzzy!throopw From: throopw@xyzzy.UUCP (Wayne A. Throop) Newsgroups: comp.unix.wizards Subject: Re: mmap( addr, len, protection, share, fd, offset ); Message-ID: <115@xyzzy.UUCP> Date: Sat, 27-Jun-87 13:22:56 EDT Article-I.D.: xyzzy.115 Posted: Sat Jun 27 13:22:56 1987 Date-Received: Sun, 28-Jun-87 04:47:49 EDT References: <540@iscuva.UUCP> <8300006@iaoobelix.UUCP> <680@nu3b2.UUCP> <684@nu3b2.UUCP> <7168@mimsy.UUCP> Organization: Data General, RTP NC. Lines: 46 > chris@mimsy.UUCP (Chris Torek) >> rwhite@nu3b2.UUCP (Robert C. White Jr.) >>OK, so whare does the file come from?? Is it in a special disk >>partition, and loaded at system boot time? > The file comes from the file system, of course. Indeed. Quite like the text area of an executable file, it is paged directly from the filesystem. Unlike the text area of an executable file, it may have to have pages written to it from memory that has been modified. An interesting question is whether sync() should force this to happen, or whether some other kernel hint should be used. Chris's summary is of course excellent: >>As I said... What's the point? > There are several: > - The new kernel runs faster (for some selected set of benchmarks); > - The new kernel code is simpler; > - Mapped file semantics are more convenient for some programs; > - Mapped files provide shared memory. ... but I thought I'd expand on the "mapped files provide shared memory" point a little. In fact, they provide it in a much cleaner and more convenient form than the shm calls from SysV. To touch on only one point, the very first problem one runs into when actually using SysV shared memory is how to allocate shmids and communicate them to all the cooperating processes. Usually, some scheme with a central administrator process and some fifos or whatnot has to be kludged together. On the other hand, with the file system providing the "schmids", which are just files (or inodes if you will), there doesn't need to be any complication. Just create a file where it will do the most good, in a place in the file system that has the protections you want, and the overflow checking you want, and all the other nice things the file system already provides. It even gives you a shared memory segement that persists longer than the machine stays up, without having to utter any extraneious incantations in the /etc/rc or equivalent. All in all, mmap-like shared memory and file-to-memory mapping is far superior, far more flexible, and could be far better integrated into the rest of unix than is SysV shmem. -- Adam and Eve had many advantages, but the principal one was, that they escaped teething. --- Pudd'nhead Wilson's Calendar (Mark Twain) -- Wayne Throop !mcnc!rti!xyzzy!throopw