Dr Damitha Karunaratna University of Colombo school of computing

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Part IV: Memory Management
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 36 Virtual Memory Read.
Allocation Methods - Contiguous
Chapter 10: File-System Interface
File Management Chapter 12. File Management A file is a named entity used to save results from a program or provide data to a program. Access control.
CS 311 – Lecture 21 Outline Memory management in UNIX
Chapter 11: File System Implementation
Modified from Silberschatz, Galvin and Gagne Lecture 16 Chapter 8: Main Memory.
File System Implementation
Chapter 12: File System Implementation
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
1 File Management in Representative Operating Systems.
1 Chapter 8 Virtual Memory Virtual memory is a storage allocation scheme in which secondary memory can be addressed as though it were part of main memory.
Chapter 9 Virtual Memory Produced by Lemlem Kebede Monday, July 16, 2001.
Computer Organization and Architecture
03/22/2004CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
File System Implementation
Main Memory. Background Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are only.
03/17/2008CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
File Management Chapter 12.
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
File Management Chapter 12. File Management File management system is considered part of the operating system Input to applications is by means of a file.
Chapter pages1 File Management Chapter 12.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 8: Main Memory.
Operating Systems Chapter 8
8.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 8: Memory-Management Strategies Objectives To provide a detailed description.
Chapter 4 Storage Management (Memory Management).
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation.
6 Memory Management and Processor Management Management of Resources Measure of Effectiveness – On most modern computers, the operating system serves.
File Management Chapter 12. File Management File management system is considered part of the operating system Input to applications is by means of a file.
Computer Studies (AL) Memory Management Virtual Memory I.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally VIRTUALMEMORY.
Chapter 4 Memory Management Virtual Memory.
Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
File System Implementation
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
Module 4.0: File Systems File is a contiguous logical address space.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 9: Virtual Memory.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
Virtual Memory Various memory management techniques have been discussed. All these strategies have the same goal: to keep many processes in memory simultaneously.
FILE SYSTEM IMPLEMENTATION 1. 2 File-System Structure File structure Logical storage unit Collection of related information File system resides on secondary.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Introduction to Operating Systems Concepts
File-System Management
Memory Management.
Chapter 8: Main Memory.
Chapter 11: File System Implementation
Chapter 9: Virtual Memory
Main Memory Management
Chapter 11: File System Implementation
Operating System Concepts
Chapter 9: Virtual-Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Module IV Memory Organization.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Main Memory Background Swapping Contiguous Allocation Paging
Chapter 8: Memory management
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Chapter 9: Virtual Memory
Contents Memory types & memory hierarchy Virtual memory (VM)
Chapter 8: Memory Management strategies
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Presentation transcript:

Dr Damitha Karunaratna University of Colombo school of computing Unit 5-6 Virtual Memory Dr Damitha Karunaratna University of Colombo school of computing Operating Systems

Virtual memory Is it necessary to load an entire program to the memory for execution? If the size of the program is larger than the available memory how can it be execute? Operating Systems

Virtual Memory - Goals Allow applications larger than physical memory to execute. Run partially loaded programs – Entire program need not to be in memory all the time. Multiprogramming: Many programs simultaneously reside in memory. Allow re-locatable programs – anywhere, anytime Application Portability: Applications should not have to manage memory resources Write machine independent code – program should not depend on memory architecture. Permit sharing of memory segments or regions. For example, read-only code segments should be shared between program instances. Operating Systems

Virtual Memory Operating Systems

Virtual memory Virtual memory is partitioned in to equal size pages. Main memory is also partitions into equal size page frames. Size of a page = size of a page frame Programs are also partitioned into pages at the time of loading. Operating Systems

Logical View Operating Systems

Virtual Memory Process runs on a virtual machine as defined by the underlying hardware. Focus is on Hardware support for a virtual address space virtual addresses independent of physical memory Key hardware component is the Memory Management Unit (MMU) address translation: virtual to physical memory ensures virtual address space protection Operating Systems

Virtual Memory Page table Keep track of whether a page is in a physical page frame or not. Page table may maintain a bit in each entry to indicate whether the page is in the memory or not. Operating Systems

Handling missing pages When a page fault occurs, the Operating System: moves the current process to the blocked/waiting state (since it must wait for a page to be made resident). finds an empty frame or, if necessary, makes a frame empty in main memory by swapping out a page in the main memory. determines the location of the requested page on the paging device. schedules a disk read operation to load the page into the selected main memory frame (via a “pagein”) later handles page fetch completion (which is recognized via an I/O completion interrupt) and then moves the blocked process back to the ready state. Operating Systems

Using Virtual Memory http://www.tutorialspoint.com/operating_system/os_virtual_memory.htm Operating Systems

Virtual Addresses Operating Systems

Virtual address to Real Address Operating Systems

Paging Example MMU CPU Physical Memory Virtual Memory Page table 2 4 4 d 1 2 3 E f 4 1 C E f A B D row 0 Page frame 0 row n Page frame 3 Page n 2 4 CPU MMU 4 Operating Systems

Using Virtual Memory Check an internal table for this process, to determine whether the reference was a valid or it was an invalid memory access. If the reference was invalid, terminate the process. If it was valid, but page have not yet brought in, page in the latter. Find a free frame. Schedule a disk operation to read the desired page into the newly allocated frame. When the disk read is complete, modify the internal table kept with the process and the page table to indicate that the page is now in memory. Restart the instruction that was interrupted by the illegal address trap. The process can now access the page as though it had always been in memory. Therefore, the operating system reads the desired page into memory and restarts the process as though the page had always been in memory. Operating Systems

Virtual Memory - Disadvantages Space: Translation tables and other data used by VM system reduce available memory to programs Time: Address translation time is added to the cost (execution time) of each instruction. Overhead: Memory management operations have been measured to consume up to 10% of the CPU time on a busy system. Efficiency: Allocating memory in pages may result in fragmentation Operating Systems

Virtual Memory Allows programmers to address memory from a logical point of view Another layer of indirection Allow the illusion of operating with a larger memory space than what is available in reality By storing some of the information on the file system Operating Systems

Device Drivers Device driver is a software. The computer communicates with peripheral devices through device drivers. A driver provides a software interface to hardware devices, enabling operating systems and other computer programs to access hardware functions without knowing the precise hardware details. Device drivers depends on both the hardware and the operating system loaded in to the computer Operating Systems

Secondary Storage Management Secondary storage is the non-volatile repository for both user and system data and programs. Secondary storage is typically used to store Source program Executable programs Data for the program Temporaty data Operating Systems

Files A file is a named collection of related information, usually a sequence of bytes A file can be viewed in two different ways. • Logical (programmer’s) view: how the users see the file. Liners collection of records. Image File – rows of intensity values Linear sequence of bytes. • Physical (operating system) view: how the file is stored on secondary storage. Many possibilities, not necessarily contiguous Operating Systems

File Attributes Each file has an associated collection of information(attributes) file name Owner type (e.g., source, data, executable) location(s) on the secondary storage. organization (e.g. sequential, indexed, random) access permissions – who is permitted to read/write/delete data in the file. time and date of creation, modification, last access file size Operating Systems

File Types File can be classified into various types based on the content. Executable Text Source Library Compressed Word Processor Spread sheet. One of the possible implementation technique of file type is to include the type as an extension to the file name. Operating Systems

File Access Methods File access methods describe how the data stored in a file can be accessed Sequential: access in order, one record after another. Direct (random): access in any order, skipping over uninteresting records Indexed : access in any order, but based on key value(s) Operating Systems

Directories Directories are used to organize file to logical categories. A directory is a file that can be searched for information about other files. Entries in the directory file are created, deleted and modified when the files they describe are create, deleted and modified. Operating Systems

Unix Directory structure Operating Systems

File allocation Common file allocation techniques Contiguous Linked Indexed Typically the allocation techniques allocate storage space on the basis of fixed size addressable units. Operating Systems

File allocation - Contiguous Allocate disk space as a collection of adjacent/contiguous blocks. This technique needs to keep track of unused disk space. Directory File Name Start Block No No of Blocks file1 00 03 file2 12 06 file3 20 11 Operating Systems

File allocation - Contiguous Advantages: Simple easy access. Easy Access. Disadvantage File size is not known at the time of creation. Extending file size is difficult External fragmentation Operating Systems

File allocation - Linked Inside each block a link is maintained to point to the next block of the file Directory File Name Start Block No No of Blocks file1 00 03 Operating Systems

File allocation - Linked Advantages: No external fragmentation. Files can grow easily. Disadvantage Many seek are required to access file data Example : MSDOS FAT file system Operating Systems

File allocation - Indexed Creates a table of pointers(index) at the time of the file creation. This table is modified as new blocks are allocated for the file or removed from the file. The index table is also saved in a block/s. Example : UNIX file system Operating Systems

Formatting a storage device Hard disks, need to be formatted before using. Formatting a disk configures the disk with a file system so that OS can store information on the disk. Operating Systems

File Allocation Table(FAT) FAT is the file systems used by Windows NT operating system. FAT uses a file allocation table (FAT) to keep track of files in the storage devices FAT and the root directory reside at a fixed location of the volume so that the system's boot files can be correctly located. To protect a volume, two copies of the FAT are kept. Operating Systems

New Technology File System NTFS (New Technology File System) is a proprietary file system developed by Microsoft. This is improvement of FAT. This improvements includes The capability to recover from some disk-related errors automatically, which FAT cannot. Improved support for larger hard disks. Better security because you can use permissions and encryption to restrict access to specific files to approved users. NTFS is a recoverable file system which keeps track of transactions against the file system in a log. http://windows.microsoft.com/en-us/windows-vista/comparing-ntfs-and-fat-file-systems Operating Systems

Memory Fragmentation Fragmentation is the unintentional division of memory into many small free areas that cannot be used effectively. External Fragmentation – total memory space exists to satisfy a request, but it is not contiguous. Internal Fragmentation – allocated memory may be slightly larger than requested memory This size difference is in memory internal to a partition, hence cannot be used for any other process. Operating Systems

Memory Fragmentation …. Compaction is a technique that can be used to deal with (external) fragmentation by moving partitions to bring many small free areas together to form a single large free area. Operating Systems

References Operating System Concepts by Avi Silberschat, Peter Baer Galvin and Greg Gagne http://codex.cs.yale.edu/avi/os-book/OS8/os8c/slide-dir/ Operating Systems