Page 371 - DCAP103_Principle of operating system
P. 371

Principles of Operating Systems



                   Notes         into the file system so another process can use it. The next two functions map and unmap files,
                                 respectively. The last one can be used by a process to map in a file currently also mapped in by
                                 a different process. In this way, two or more processes can share regions of their address spaces.
                                 This technique allows them to write in limited regions of each other’s memory.

                                 12.3.3 Implementation of Memory Management

                                 Windows 2000 supports a single linear 4 GB demand-paged address space per process.
                                 Segmentation is not supported in any form. Theoretically, page sizes can be of any power
                                 of two up to 64 KB. On the Pentium they are fixed at 4 KB; on the Itanium they can be 8 KB
                                 or 16 KB. In addition, the operating system itself can use 4 MB pages to reduce page table
                                 space consumed.
                                 Unlike the scheduler, which selects individual threads to run and does not care much about
                                 processes, the memory manager deals entirely with processes and does not care much about
                                 threads. After all, processes, not threads, own the address space and that is what the memory
                                 manager deals with. When a region of virtual address space is allocated, as four of them have
                                 been for process  A  in  Figure  12.10,  the  memory  manager  creates  a  VAD (Virtual Address
                                 Descriptor) for it, listing the range of addresses mapped, the backing store file and offset where
                                 it is mapped, and the protection code. When the first page is touched, the directory of page
                                 tables is created and a pointer to it inserted is in the VAD. In fact, an address space is completely
                                 defined by the list of its VADs. This scheme supports sparse address spaces because unused
                                 areas between the mapped regions use no resources.

                                 12.3.4 Page Fault Handling

                                 Windows 2000 does not use any form of prepaging. When a process starts, none of its pages
                                 are in memory. All of them are brought in dynamically as page faults occurs. On each page
                                 fault, a trap to the kernel occurs. The kernel builds a machine-independent descriptor telling
                                 what happened and passes this to the memory manager part or the executive. The memory
                                 manager then checks it for validity. If the faulted page falls within a committed or reserved
                                 region, it looks up the address in the list of VADs, finds (or creates) the page table, and looks
                                 up the relevant entry.

                                 The page table entries are different for different architectures. For the Pentium, the entry for a
                                 mapped page is shown in Figure 12.12. Unmapped pages also have entries, but their format is
                                 somewhat different. For example, for an unmapped page that must be zeroed before it may be
                                 used, that fact is noted in the page table.


                                           Figure 12.12: A Page Table Entry for a Mapped Page on the Pentium


                                   Bits                   20                     3    111111111
                                                                                Not               W
                                                      Page frame               used   G  L DA C   t  UWV

                                      G: Page is global to all processes   Wt: Write through (no caching)
                                      L: Large (4 MB) page                 U: Page is accessible in user mode
                                      D: Page is dirty                     W: Writing to the page permitted
                                      A: Page has been accessed            V: Valid page table entry
                                      C: Caching enabled/disabled



        364                               LOVELY PROFESSIONAL UNIVERSITY
   366   367   368   369   370   371   372   373   374   375   376