Memory Management All data in memory before and after processing

Slides:



Advertisements
Similar presentations
Computer-System Structures Er.Harsimran Singh
Advertisements

Interactive lesson about operating system
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: Computer-System Structures
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
OS2-1 Chapter 2 Computer System Structures. OS2-2 Outlines Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Abhinav Kamra Computer Science, Columbia University 2.1 Operating System Concepts Silberschatz, Galvin and Gagne  2002 Chapter 2: Computer-System Structures.
Modified from Silberschatz, Galvin and Gagne ©2009 CS 446/646 Principles of Operating Systems Lecture 1 Chapter 1: Introduction.
Computer Organization and Architecture
Computer-System Structures
Lecture 1: Introduction CS170 Spring 2015 Chapter 1, the text book. T. Yang.
1/21/2010CSCI 315 Operating Systems Design1 Computer System Structures Notice: The slides for this lecture have been largely based on those accompanying.
What do operating systems do? manage processes manage memory and computer resources provide security features execute user programs make solving user.
Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts What is an Operating System? A program that acts as an intermediary.
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
Process Management A process is a program in execution. It is a unit of work within the system. Program is a passive entity, process is an active entity.
Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 1: Introduction What Operating Systems Do Computer-System Organization.
Objectives To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 8: Main Memory.
OS provide a user-friendly environment and manage resources of the computer system. Operating systems manage: –Processes –Memory –Storage –I/O subsystem.
2.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 2: Computer-System Structures Computer System Operation I/O Structure.
CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 2: Computer-System Structures Computer System Operation I/O Structure.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: Computer-System Structures
Thanks to Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2 Computer-System Structures n Computer System Operation n I/O Structure.
1 CSE Department MAITSandeep Tayal Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
2: Computer-System Structures
Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 1: Introduction What Operating Systems Do (previous.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure.
2.1 Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation Storage Structure Storage Hierarchy Hardware Protection General.
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.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 4 Computer Systems Review.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 2: Computer-System Structures Computer System Architecture and Operation.
Review of Computer System Organization. Computer Startup For a computer to start running when it is first powered up, it needs to execute an initial program.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: Computer-System Structures(Hardware) or Architecture or Organization Computer System Operation I/O Structure Storage Structure Storage Hierarchy.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 4.
Chapter 1: Introduction Narzu Tarannum(NAT) Reff: BIS.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 1: Introduction.
Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives To provide a grand tour of the major operating.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: The Linux System Part 4
Chapter 2: Computer-System Structures(Hardware)
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Chapter 9: Virtual Memory
Chapter 1: Introduction
Chapter 18: The Linux System
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
10CS53 Operating Systems Unit VIII Engineered for Tomorrow
Page Replacement.
10CS53 Operating Systems Unit VIII Engineered for Tomorrow
Computer-System Architecture
Module 2: Computer-System Structures
Chapter 2: Operating-System Structures
Introduction to Operating Systems
Module 2: Computer-System Structures
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Module 2: Computer-System Structures
Chapter 2: Operating-System Structures
Module 2: Computer-System Structures
Components of a Linux System
Presentation transcript:

Memory Management All data in memory before and after processing All instructions in memory in order to execute Memory management determines what is in memory when Optimizing CPU utilization and computer response to users Memory management activities Keeping track of which parts of memory are currently being used and by whom Deciding which processes (or parts thereof) and data to move into and out of memory Allocating and deallocating memory space as needed

Device-Status Table

Storage Structure Main memory – only large storage media that the CPU can access directly. Secondary storage – extension of main memory that provides large nonvolatile storage capacity. Magnetic disks – rigid metal or glass platters covered with magnetic recording material Disk surface is logically divided into tracks, which are subdivided into sectors. The disk controller determines the logical interaction between the device and the computer.

Storage-Device Hierarchy

Caching Important principle, performed at many levels in a computer (in hardware, operating system, software) Information in use copied from slower to faster storage temporarily Faster storage (cache) checked first to determine if information is there If it is, information used directly from the cache (fast) If not, data copied to cache and used there Cache smaller than storage being cached Cache management important design problem Cache size and replacement policy

Performance of Various Levels of Storage Movement between levels of storage hierarchy can be explicit or implicit

Migration of Integer A from Disk to Register Multitasking environments must be careful to use most recent value, no matter where it is stored in the storage hierarchy Multiprocessor environment must provide cache coherency in hardware such that all CPUs have the most recent value in their cache Distributed environment situation even more complex Several copies of a datum can exist Various solutions covered in Chapter 17

Storage Management OS provides uniform, logical view of information storage Abstracts physical properties to logical storage unit - file Each medium is controlled by device (i.e., disk drive, tape drive) Varying properties include access speed, capacity, data-transfer rate, access method (sequential or random) File-System management Files usually organized into directories Access control on most systems to determine who can access what OS activities include Creating and deleting files and directories Primitives to manipulate files and dirs Mapping files onto secondary storage Backup files onto stable (non-volatile) storage media

Memory Management Linux’s physical memory-management system deals with allocating and freeing pages, groups of pages, and small blocks of memory It has additional mechanisms for handling virtual memory, memory mapped into the address space of running processes Splits memory into 3 different zones due to hardware characteristics

Relationship of Zones and Physical Addresses on 80x86

Splitting of Memory in a Buddy Heap

Managing Physical Memory The page allocator allocates and frees all physical pages; it can allocate ranges of physically-contiguous pages on request The allocator uses a buddy-heap algorithm to keep track of available physical pages Each allocatable memory region is paired with an adjacent partner Whenever two allocated partner regions are both freed up they are combined to form a larger region If a small memory request cannot be satisfied by allocating an existing small free region, then a larger free region will be subdivided into two partners to satisfy the request Memory allocations in the Linux kernel occur either statically (drivers reserve a contiguous area of memory during system boot time) or dynamically (via the page allocator) Also uses slab allocator for kernel memory

21.07

Virtual Memory The VM system maintains the address space visible to each process: It creates pages of virtual memory on demand, and manages the loading of those pages from disk or their swapping back out to disk as required The VM manager maintains two separate views of a process’s address space: A logical view describing instructions concerning the layout of the address space The address space consists of a set of nonoverlapping regions, each representing a continuous, page-aligned subset of the address space A physical view of each address space which is stored in the hardware page tables for the process

Virtual Memory (Cont.) Virtual memory regions are characterized by: The backing store, which describes from where the pages for a region come; regions are usually backed by a file or by nothing (demand-zero memory) The region’s reaction to writes (page sharing or copy-on-write) The kernel creates a new virtual address space 1. When a process runs a new program with the exec system call 2. Upon creation of a new process by the fork system call

Virtual Memory (Cont.) On executing a new program, the process is given a new, completely empty virtual-address space; the program-loading routines populate the address space with virtual-memory regions Creating a new process with fork involves creating a complete copy of the existing process’s virtual address space The kernel copies the parent process’s VMA descriptors, then creates a new set of page tables for the child The parent’s page tables are copied directly into the child’s, with the reference count of each page covered being incremented After the fork, the parent and child share the same physical pages of memory in their address spaces

Virtual Memory (Cont.) The VM paging system relocates pages of memory from physical memory out to disk when the memory is needed for something else The VM paging system can be divided into two sections: The pageout-policy algorithm decides which pages to write out to disk, and when The paging mechanism actually carries out the transfer, and pages data back into physical memory as needed

Virtual Memory (Cont.) The Linux kernel reserves a constant, architecture-dependent region of the virtual address space of every process for its own internal use This kernel virtual-memory area contains two regions: A static area that contains page table references to every available physical page of memory in the system, so that there is a simple translation from physical to virtual addresses when running kernel code The reminder of the reserved section is not reserved for any specific purpose; its page-table entries can be modified to point to any other areas of memory

Executing and Loading User Programs Linux maintains a table of functions for loading programs; it gives each function the opportunity to try loading the given file when an exec system call is made The registration of multiple loader routines allows Linux to support both the ELF and a.out binary formats Initially, binary-file pages are mapped into virtual memory Only when a program tries to access a given page will a page fault result in that page being loaded into physical memory An ELF-format binary file consists of a header followed by several page- aligned sections The ELF loader works by reading the header and mapping the sections of the file into separate regions of virtual memory

Memory Layout for ELF Programs

Static and Dynamic Linking A program whose necessary library functions are embedded directly in the program’s executable binary file is statically linked to its libraries The main disadvantage of static linkage is that every program generated must contain copies of exactly the same common system library functions Dynamic linking is more efficient in terms of both physical memory and disk-space usage because it loads the system libraries into memory only once