| Page (computer Science) |
Article Index for Page |
Articles about Paging |
Website Links For Paging |
Information AboutPage (computer Science) |
| CATEGORIES ABOUT PAGING | |
| virtual memory | |
| memory management | |
|
In Computer Operating System s, paging Memory Allocation Algorithm s divide Computer Memory into small partitions, and allocates memory using a Page as the smallest building block. ADVANTAGES A key advantage that this method has over simpler methods such as the Buddy Memory Allocation technique and dynamic allocation techniques is that the memory allocated to a program does not have to be contiguous, and because of that, there is very little External Fragmentation - thus little memory is wasted. Because programs rarely use all parts of their code and data at one point in time, the concept of Virtual Memory can be implemented by writing pages to disk, and reading pages from disk when they are needed. This is another advantage of paging over other memory allocation techniques. DISADVANTAGES The only major disadvantage of paging is the relatively complicated nature of the code required to handle it, especially if Virtual Memory is to be implemented. Otherwise, there are only minor disadvantages such as the need for a Memory Management Unit (MMU), which means that paging cannot be implemented on some older or smaller processors (in the Intel X86 family, for example, only 80386 and higher CPUs possess MMUs). It is also possible for internal fragmentation to occur, when, for example, a little more memory is required to store some data than the size of a page. In this case, a whole new page must be allocated to that data, while only a small fraction of the potential storage space within that page is being used. This kind of fragmentation also occurs when less memory is required to save some data than the size of a page. HOW IT WORKS The memory access part of paging is done at the hardware level via Page Table s, and is handled by the Memory Management Unit (MMU for short). As mentioned earlier, physical memory is divided into small blocks called pages (typically 4 kilobytes or less) in size, and each block is assigned a page number. The Operating System may keep a list of free pages in its memory, or may choose to probe the memory each time a memory request is made (though most modern operating systems do the former). Whatever the case, when a program makes a request for memory, the operating system allocates a number of pages to the program, and keeps a list of allocated pages for that particular program in memory. Now, let us take a look at an example. The above table is a possible page allocation list. (4K pages) This allocation could have happened in the following order #Program A requests 3 pages of memory #Program C requests 2 pages of memory #Program D requests 2 pages of memory #Program C terminates, leaving 2 empty pages #Program B requests 3 pages of memory, and it is allocated the 2 empty pages that program C left, plus an additional page after program D Consequently, Program A's page tables would contain the following mapping (Program's Page #=>OS Page #): (0=>0, 1=>1, 2=>2); Program B's : (0=>3,1=>4,2=>7); and Program D's : (0=>5, 1=>6). Now lets consider what happens when a program wants to access its own memory. Let's say Program A contains a statement "LOAD memory at 20FE". What happens? Let's take a look at it now. 20FE is 0010000011111110 in binary notation (in a 16-bit system), and we have pages of 4K in size. So when a request for memory at 20FE is made, the MMU looks at it in this way :
|