📄 1.t
字号:
.\" Copyright (c) 1990 The Regents of the University of California..\" All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\" must display the following acknowledgement:.\" This product includes software developed by the University of.\" California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\" may be used to endorse or promote products derived from this software.\" without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\" @(#)1.t 5.1 (Berkeley) 4/16/91.\".nr PS 11.nr VS 13.SHIntroduction.PPThis paper describes the motivation for and implementation ofa memory-based filesystem.Memory-based filesystems have existed for a long time;they have generally been marketed as RAM disks or sometimesas software packages that use the machine's general purpose memory..[white.].PPA RAM disk is designed to appear like any other disk peripheralconnected to a machine.It is normally interfaced to the processor through the I/O busand is accessed through a device driver similar or sometimes identicalto the device driver used for a normal magnetic disk.The device driver sends requests for blocks of data to the deviceand the requested data is then DMA'ed to or from the requested block.Instead of storing its data on a rotating magnetic disk,the RAM disk stores its data in a large array of random access memoryor bubble memory.Thus, the latency of accessing the RAM disk is nearly zerocompared to the 15-50 milliseconds of latency incurred whenaccess rotating magnetic media.RAM disks also have the benefit of being able to transfer data atthe maximum DMA rate of the system,while disks are typically limited by the rate that the data passesunder the disk head..PPSoftware packages simulating RAM disks operate by allocatinga fixed partition of the system memory.The software then provides a device driver interface similarto the one described for hardware RAM disks,except that it uses memory-to-memory copy instead of DMA to movethe data between the RAM disk and the system buffers,or it maps the contents of the RAM disk into the system buffers.Because the memory used by the RAM disk is not available forother purposes, software RAM-disk solutions are used primarilyfor machines with limited addressing capabilities such as PC'sthat do not have an effective way of using the extra memory anyway..PPMost software RAM disks lose their contents when the system is powereddown or rebooted.The contents can be saved by using battery backed-up memory,by storing critical filesystem data structures in the filesystem,and by running a consistency check program after each reboot.These conditions increase the hardware costand potentially slow down the speed of the disk.Thus, RAM-disk filesystems are not typicallydesigned to survive power failures;because of their volatility, their usefulness is limited to transientor easily recreated information such as might be found in.PN /tmp .Their primary benefit is that they have higher throughputthan disk based filesystems..[smith.]This improved throughput is particularly useful for utilities thatmake heavy use of temporary files, such as compilers.On fast processors, nearly half of the elapsed time for a compilationis spent waiting for synchronous operations required for filecreation and deletion.The use of the memory-based filesystem nearly eliminates this waiting time..PPUsing dedicated memory to exclusively support a RAM diskis a poor use of resources.The overall throughput of the system can be improvedby using the memory where it is getting the highest access rate.These needs may shift between supporting process virtual address spacesand caching frequently used disk blocks.If the memory is dedicated to the filesystem,it is better used in a buffer cache.The buffer cache permits faster access to the databecause it requires only a single memory-to-memory copyfrom the kernel to the user process.The use of memory is used in a RAM-disk configuration may require twomemory-to-memory copies, one from the RAM diskto the buffer cache,then another copy from the buffer cache to the user process..PPThe new work being presented in this paper is building a prototypeRAM-disk filesystem in pageable memory instead of dedicated memory.The goal is to provide the speed benefits of a RAM diskwithout paying the performance penalty inherent in dedicatingpart of the physical memory on the machine to the RAM disk.By building the filesystem in pageable memory,it competes with other processes for the available memory.When memory runs short, the paging system pushes itsleast-recently-used pages to backing store.Being pageable also allows the filesystem to be much larger thanwould be practical if it were limited by the amount of physicalmemory that could be dedicated to that purpose.We typically operate our.PN /tmpwith 30 to 60 megabytes of spacewhich is larger than the amount of memory on the machine.This configuration allows small files to be accessed quickly,while still allowing.PN /tmpto be used for big files,although at a speed more typical of normal, disk-based filesystems..PPAn alternative to building a memory-based filesystem would be to havea filesystem that never did operations synchronously and neverflushed its dirty buffers to disk.However, we believe that such a filesystem would eitheruse a disproportionately large percentage of the buffercache space, to the detriment of other filesystems,or would require the paging system to flush its dirty pages.Waiting for other filesystems to push dirty pagessubjects them to delays while waiting for the pages to be written.We await the results of others trying this approach..[Ohta.].SHImplementation.PPThe current implementation took less time to write than did this paper.It consists of 560 lines of kernel code (1.7K text + data)and some minor modifications to the program that buildsdisk based filesystems, \fInewfs\fP.A condensed version of the kernel code for thememory-based filesystem are reproduced in Appendix 1..PPA filesystem is created by invoking the modified \fInewfs\fP, withan option telling it to create a memory-based filesystem.It allocates a section of virtual address space of the requestedsize and builds a filesystem in the memoryinstead of on a disk partition.When built, it does a \fImount\fP system call specifying a filesystem type of.SM MFS(Memory File System).The auxiliary data parameter to the mount call specifies a pointerto the base of the memory in which it has built the filesystem.(The auxiliary data parameter used by the local filesystem, \fIufs\fP,specifies the block device containing the filesystem.).PPThe mount system call allocates and initializes a mount tableentry and then calls the filesystem-specific mount routine.The filesystem-specific routine is responsible for doingthe mount and initializing the filesystem-specificportion of the mount table entry.The memory-based filesystem-specific mount routine,.RN mfs_mount ,is shown in Appendix 1.It allocates a block-device vnode to represent the memory disk device.In the private area of this vnode it stores the base address ofthe filesystem and the process identifier of the \fInewfs\fP processfor later reference when doing I/O.It also initializes an I/O list that ituses to record outstanding I/O requests.It can then call the \fIufs\fP filesystem mount routine,passing the special block-device vnode that it has createdinstead of the usual disk block-device vnode.The mount proceeds just as any other local mount, except thatrequests to read from the block device are vectored through.RN mfs_strategy(described below) instead of the usual.RN spec_strategy
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -