Lyna has tutored undergraduate Information Management Systems and Database Development. She has a Bachelor's degree in Electrical Engineering and a Masters degree in Information Technology.
What Is Memory Paging?
Memory paging is a memory management technique used by the operating system (OS) to manage how a computer's memory resources are shared. Processes being executed are done so within memory.
Paged memory allocation is the process of storing a portion of an executing process on disk or secondary memory. Main memory, or RAM, has fast access times but comparatively low storage capacity. There are some programs that are too big to fit completely into the system's main memory. This is where paging comes into play. Let's look at how a program or task is managed when it's too large to run in main memory all at once.
Memory is divided up into sections or chunks called frames. A frame is fixed in size and is a unit of physical memory. Frames are the placeholders or storage spaces for pages, the parts or chunks of an executing process or task and represent a logical unit of memory.
Think of memory as an ice tray. The compartments (frames), each hold a specific amount (memory allocation) of water. A full glass of water (the complete process or task) is poured into the compartments to break up its full amount. A frame can be greater or equal in capacity to a page size.
Our computing systems today are built to multitask. Every program or application on a system cannot be executed without the use of the main memory. If memory was just one large single compartment of space, only one task would be executed at a time. To enable multitasking, memory is partitioned or compartmentalized into frames. Processes requesting memory for execution are allocated to suitable frames in memory.
Memory Page Allocation
Consider Tasks A, B, and C that need to be loaded into memory for execution. We have a total memory space sized at 32Mb. Memory frames have been partitioned into 4Mb compartments. An area is reserved exclusively for the operating system.
Task A requires 8Mb of memory for execution. This means that task A will have to be allocated two 4Mb frames. This is indicated by pages A0 and A1 in main memory.
Task B requires 11Mb of memory for execution. This means Task B will have to be allocated three 4Mb frames denoted by pages B0, B1, and B2, to accommodate its size.
Task C requires less than 4Mb, but will have to occupy one 4MB frame, shown as page C0
So what happens to the unoccupied spaces within the frames allocated to pages B2 and C0? These spaces are referred to as internal fragmentation in memory, which occurs when allocated memory is larger than the requested memory. Memory is precious, and fragmentation can be a disadvantage.
We must note however, that pages do not need to be allocated in contiguous spaces in memory for tasks to be executed successfully. We see that page B0 is followed by page B1, which follows with page B2. This is not always the case. Process A, for example, can complete execution and be removed from memory to allow other awaiting tasks to load into memory.
Let's introduce Task D as a 16Mb process waiting to be loaded into memory. The frames previously occupied by Process A are now available, and process D is allocated these frames as denoted by pages D0 and D1.
The rest of the pages for process D are allocated in frames located after the pages of tasks B and C, as seen. The non-contiguous frames into which pages of Task D are loaded do not affect its execution. An empty frame can be used by any task.
Frame use has to be tracked and monitored by the operating system (OS) to ensure that as processes are swapped in and out of memory, task executions are not impacted. The OS must know the location of every page. The OS does this by using page tables, which we'll talk about in a bit.
Demand and Page Tables
Demand page memory allocation is the technique in which pages within a particular process or task are swapped in and out of main memory from secondary memory as required for execution. This process is also tracked through the use of page tables.
Page tables are used to track and locate where the different pages of a process or task are located in memory (frames). A page table shows the mapping of physical address locations with virtual address locations. Because pages of a process can occupy non-contiguous frames positions, the OS needs to keep track of where each page is stored.
To better understand page tables, we will first assign frame identifiers called addresses (usually stored in hexadecimal format) to the memory frames. This way, we are able to determine which particular frame stores the page of a particular task.
The columns in each table identify the task or process (PT B, PT C and PT D). Each page table (PT) consists of rows. Each row stores the mapping information of the different pages within that task. The first row therefore represents the mapping information for the first page (denoted by page 0); the next row contains the mapping information for page 1; and so on for that specific process.
Let's take PT D for example. PT D consists of 4 rows. This means that task D was split into 4 pages. D0 (page 0 of task D) is stored in frame addressed 001.
The ability of systems to multitask is key, and memory is at the core of it all. Programs need to be loaded into memory for execution, but sometimes these programs are too large to be held in memory all at once. The OS therefore implements a paging system. Tasks are split into fixed sizes called pages and loaded into memory as and when needed.
Paged memory allocation is a memory management technique in which the OS controls the way memory is shared among different processes or tasks.
Memory is partitioned into frames that hold the different pages of executing tasks while the remainder of the program is kept in secondary memory until needed. The process of swapping pages from main memory to secondary memory and back is called demand page memory allocation.
The OS keeps track of what's stored where through the use of page tables, which show the mapping of physical address locations with virtual address locations.
To unlock this lesson you must be a Study.com Member.
Create your account
Register to view this lesson
Unlock Your Education
See for yourself why 30 million people use Study.com
Become a Study.com member and start learning now.Become a Member
Already a member? Log InBack