Page 163 - DCAP103_Principle of operating system
P. 163

Principles of Operating Systems



                   Notes         plus  1,086  bytes.  It  would  be  allocated  36  frames,  resulting  in  an  internal  fragmentation  of
                                 2048 — 1086 = 962 bytes. In the worst case, a process would need n pages plus one byte. It would
                                 be allocated n + 1 frames, resulting in an internal fragmentation of almost an entire frame. If
                                 process size is independent of page size, we expect internal fragmentation to average one-half
                                 page  per  process.  This  consideration  suggests  that  small  page  sizes  are  desirable.  However,
                                 overhead is involved in each page-table entry, and this overhead is reduced as the size of the
                                 pages increases. Also, disk I/O is more efficient when the number of data being transferred is
                                 larger. Generally, page sizes have grown over time as processes, data sets, and main memory
                                 have become larger. Today pages typically are between KB and 8 KB, and some systems support
                                 even larger page sizes. Some CPUs and kernels even support multiple page sizes. For instance,
                                 Solaris uses 8 KB and 4 MB page sizes, depending on the data stored by the pages. Researchers
                                 are now developing variable on-the-fly page-size support. Each page-table entry is usually 4
                                 bytes long, but that size can vary as well. A 32-bit entry can point to one of 232 physical page
                                 frames. If a frame is 4 KB, then a system with 4-byte entries can address 236 bytes (or 64 GB)
                                 of physical memory. When a process arrives in the system to be executed, its size, expressed in
                                 pages, is examined. Each page of the process needs one frame. Thus, if the process requires n
                                 pages, at least n frames must be available in memory. If n frames are available, they are allocated
                                 to this arriving process. The first page of the process is loaded into one of the allocated frames,
                                 and the frame number is put in the page table for this process.
                                           Figure 5.7: Paging Examples for a 32-byte Memory with 4-byte Pages


















































        156                               LOVELY PROFESSIONAL UNIVERSITY
   158   159   160   161   162   163   164   165   166   167   168