Page 164 - DCAP103_Principle of operating system
P. 164

Unit 5: Memory Management



            An important aspect of paging is the clear separation between the user’s view of memory and   Notes
            the actual physical memory. The user program views that memory as one single contiguous
            space, containing only this one program.

                     Figure 5.8: Free Frames: (a) Before Allocation and (b) After Allocation

































            In fact, the user program is scattered throughout physical memory, which also holds other
            programs. The difference between the user’s view of memory and the actual physical memory
            is reconciled by the address-translation hardware. The logical addresses are translated into
            physical addresses. This mapping is hidden from the user and is controlled by the operating
            system. Notice that the user process by definition is unable to access memory it does not
            own. It has no way of addressing memory outside of its page table, and the table includes
            only those pages that the process owns. Since the operating system is managing physical
            memory, it must be aware of the allocation details of physical memory—which frames are
            allocated,  which  frames  are  available,  how  many  total  frames  there  are,  and  so  on.  This
            information is generally kept in a data structure called a frame table. The frame table has
            one entry for each physical page frame, indicating whether the latter is free or allocated and,
            if it is allocated, to which page of which process or processes. In addition, the operating
            system must be aware that user processes operate in user space, and all logical addresses
            must be mapped to produce physical addresses. If a user makes a system call (to do I/O,
            for example) and provides an address as a parameter (a buffer, for instance), that address
            must be mapped to produce the correct physical address. The operating system maintains a
            copy of the page table for each process, just as it maintains a copy of the instruction counter
            and register contents. This copy is used to translate logical addresses to physical addresses
            whenever the operating system must map a logical address to a physical address manually.
            It is also used by the CPU dispatcher to define the hardware page table when a process is
            to be allocated the CPU. Paging therefore increases the context-switch time.






                                             LOVELY PROFESSIONAL UNIVERSITY                                   157
   159   160   161   162   163   164   165   166   167   168   169