Page 401 - DCAP103_Principle of operating system
P. 401

Principles of Operating Systems



                   Notes         Let us now examine how the cache manager works. When a file is referenced, the cache manager
                                 maps a 256 KB chunk of kernel virtual address space onto the file. If the file is larger than 256
                                 KB, only a portion of the file is mapped. The total amount of virtual address space the cache
                                 manager can use is determined at boot time and depends on the amount of RAM present. If
                                 the cache manager runs out of 256 KB chunks of virtual address space, it must unmap an old
                                 file before mapping in a new one.
                                 Once a file is mapped, the cache manager can satisfy requests for its blocks by just copying from
                                 kernel virtual address space to the user buffer. If the block copied is not in physical memory,
                                 a page fault will occur and the memory manager will satisfy the fault in the usual away. The
                                 cache manager is not even aware of whether the block was in the cache or not. The copy always
                                 succeeds.

                                 The operation of the cache manager is shown in Figure 13.16 in the case of an NTFS file system
                                 on a SCSI disk and a FAT-32 file system on an IDE disk. When a process does a read on a file,
                                 the request is directed to the cache manager. If the block needed is in the cache, it is copied to
                                 the user immediately. If it is not in the cache, the cache manager gets a page fault when trying
                                 to copy it. When the page fault has been handled, the block is copied to the calling process.

                                               Figure 13.16: The Path Through the Cache to the Hardware


































                                 As a consequence of this design, the cache manager does not know how many of its mapped
                                 pages are in physical memory or even how large its cache is. Only the memory manager knows
                                 for sure. This approach allows the memory manager to dynamically trade off the size of the
                                 cache against memory for user pages. If there is little file activity but there are many processes
                                 active, the memory manager can use most of physical memory for process pages. On the other
                                 hand, if there is a lot of file activity and few processes, more physical memory can be devoted
                                 to the cache.

                                 Another property the cache manager has is that coherence is maintained between memory-
                                 mapped files and the files that are open for reading and writing. Consider, for example, a situation




        394                               LOVELY PROFESSIONAL UNIVERSITY
   396   397   398   399   400   401   402   403   404   405   406