Download presentation
Presentation is loading. Please wait.
Published byNigel Underwood Modified over 9 years ago
1
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally VIRTUALMEMORY
2
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally To execute a program, the entire process should be loaded into the main memory. Thus the size of the process is limited to the size of the physical memory. A memory management scheme called “Overlaying” can be used to overcome this situation. Introduction
3
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally The programmer splits a program into smaller parts called overlays in such a way that no two overlays are required to be in main memory at the same time. An overlay is loaded into memory only when it is needed. One major disadvantage of this technique is that it requires major involvement of the programmer and time consuming. Overlaying
4
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally Virtual memory is a technique that allows execution of a program that is bigger than the physical memory of the computer system. In this technique, the operating system loads only those parts of program in memory that are currently needed for the execution of the process. The rest part is kept in the disk and is loaded into memory only when needed. Virtual Memory – overview
5
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally Virtual Memory – overview
6
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally Virtual memory gives the illusion that the system has a much larger memory than is actually available. Virtual memory frees programs from the constraints of physical memory limitation. The virtual memory can be implemented by: Demand Paging. Demand Segmentation. Virtual Memory – overview
7
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally Demand paging is a system which a page is loaded into the memory only when it is needed during program execution. Pages that are never accessed are never loaded into the memory. A demand paging system combines the features of paging with swapping. To facilitates swapping, the entire virtual address space is stored contiguously on the disk. Demand Paging
8
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally Whenever a process is to be executed, an area on the disk is allocated to it on which pages are copied, called swap space of the process. During the execution of a process, whenever a page is required, it is loaded into the main memory from the swap space. Similarly, when a process is to be removed from main memory, it is written back into the swap space if it has been modified. Demand Paging
9
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally Other than swap space, some form of hardware support is also needed to differentiate the pages that are in memory from the ones on disk. For this, only an additional bit valid is maintained in each page table entry to indicate whether the page is in memory. If a page is valid, that is it exists in the virtual address space of the process, the associated valid bit is set to 1, otherwise it is set to 0. Demand Paging
10
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally Demand Paging
11
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally Whenever a process request for a page, the virtual address is sent to MMU. The MMU checks the valid bit in the page table entry of that page. If the valid bit is 1, it is access as in paging. Otherwise, the MMU raises an interrupt called page fault or a missing page interrupt and the control is passed to the page fault routine in the operating system. Demand Paging
12
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally Demand Paging
13
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally To handle the page fault, the page fault routine first of all checks whether the virtual address for the desired page is valid from its PCB stored in the process table. If it is invalid, it terminates the process giving error. Otherwise, it takes the following steps: Demand Paging - Handing Page Fault
14
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally 1.Location for a free page frame in memory and allocation it to the process. 2.Swaps the desired page into this allocated page frame. 3.Update the process table and page table to indicate that the page is in memory. After performing these steps, the CPU restarts from the instruction that it left off due to the page fault. Demand Paging - Handing Page Fault
15
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally In demand paging, the process of loading a page in memory is known as page-in operation instead of swap-in. It is because the whole process is not loaded; only some pages are loaded into the memory. Demand Paging – page-in
16
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally It reduces the swap time since only the required pages are swapped in instead of the whole process. It increases the degree of multiprogramming by reducing the amount of physical memory required for a process. It minimizes the initial disk overhead as not all pages are to be read initially. It does not need extra hardware support. Demand Paging - Advantages
17
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally A process may need to create several processes during its execution and the parent and child processes have their own distinct address spaces. If the newly created process is the duplicate of the parent process, it will contain the same pages in its address space as that of parent. In this case, copying the parent’s address space may be unnecessary. To avoid copying, copy-on-write – a virtual memory technique can be employed. COPY-ON-WRITE
18
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally In this technique, initially, parent and child processes are allowed to share the same pages and these shared pages are marked as copy-on-write pages. Now, if either process attempts to write on a shared page, a copy of that page is created for that process. Only the pages that can be modified (containing data) are marked as copy- on-write pages while the pages that cannot be modified (containing executable code) are shared between parent and child processes. COPY-ON-WRITE
19
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally To implement this, a bit is associated in page table entry of each shared page to indicate that it is a copy-on-write page. Whenever either process say, child process tries to modify a page, the operating system creates a copy of that page, maps it to the address space of the child process and turns off the copy-on-write bit. Now the child process can modify the copied page without affecting the page of the parent process. Thus, it saves memory. COPY-ON-WRITE
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.