Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization

Size: px
Start display at page:

Download "Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization"

Transcription

1 Requirements Relocation Memory management ability to change process image position Protection ability to avoid unwanted memory accesses Sharing ability to share memory portions among processes Logical organization structure of process image Physical organization structure of the physical memory hierarchy Terms Relocation: program loading Frame A fixed-length block of main memory. Page A fixed-length block of data that resides in secondary memory. Segment May temporarily be copied into a frame of main memory. sources compiler Compiling/ Assembling.o Development linker Linking binary executable loader Loading process image Memory load address A variable-length block of data that resides in secondary memory. Segmentation A whole segment may temporarily be copied into a an available region of main memory. Combined segmentation and paging A segment may be divided into pages which can be individually copied into main memory.

2 Relocation: addressing requirements Relocation: binding load address increasing address values code data stack process image branch, function call data reference stack pointer Binding translation of references to memory addresses e.g. call strlen call 0x mov R0, errno mov R0, 0x Static compile time absolute code binary executable contains absolute addresses load address must be known at compile time if load address changes, program must be recompiled load time relocatable code binary executable contains relative addresses e.g. offset from program counter (PC+0x10fe) loader translates relative addresses to absolute addresses (static relocation) Dynamic run time relocatable code binary executable contains relative addresses CPU manages relative addresses process image can be moved during execution (dynamic reloocation) Relocation: binding Relocation: binding main call myfunc 0x x call 0x307f000 main call myfunc start start+0x1000 start+0x1100 call +0xdf00 0x x x call 0x200f000 program.o linking program.o linking loading myfunc 0x307f000 myfunc start + 0xf000 load address: 0x x200f000 module.o executable load address: 0x (fixed) module.o executable process image Compile time binding Load time binding

3 Relocation: binding Linking main call myfunc program.o linking start start+0x1000 start+0x1100 call +0xdf00 loading 0x x x call +0xdf00 Static modules and libraries are linked into an executable binary Dynamic myfunc start + 0xf000 executable load address: 0x x200f000 process image modules and static libraries are linked into an executable binary dynamic libraries are inserted only as a reference loaded at load time or at run time when needed module.o Run time binding Loading Memory partitioning Static the whole executable is loaded into memory Dynamic code is loaded only when needed Fixed partitioning Main memory is divided into a number of static partitions. 1.Same size for all partitions 2.Different partition sizes A process may be loaded into a partition of equal or greater size. Simple to implement; little operating system overhead Inefficient use of memory due to fragmentation internal (space wasted into a partition) external (partitions available cannot accommodate processes) Maximum number of active processes is fixed.

4 Fixed partitioning: examples Fixed partitioning: process assignment 2 MB 4 MB 6 MB 12 MB 16 MB new processes long-term scheduling A queue for each partition assign a process to the smallest (big enough) partition non-optimal queue i non-empty queue i+1 empty Fixed partitioning equal-size partitions (of each) Fixed partitioning unequal-size partitions Fixed partitioning: process assignment Memory partitioning An unique queue (which policy?) Dynamic partitioning First-came first-served (FCFS) simple Best-fit non-optimal memory usage Partitions are created dynamically Each process matches exactly partition size No internal fragmentation new processes Best-available-fit choose the first job that fits into partition Efficient use of main memory. Need for compaction To avoid external fragmentation.

5 Dynamic partitioning: example Dynamic partitioning: process assignment process 1 process 2 16 MB process 1 16 MB process 1 process 3 process 5 12 MB Best-fit choose the partition with closest size to the request small fragments residual First-fit process 3 process 4 process 5 6 MB 12 MB process 3 process 5 6 MB 12 MB process 6 20 MB 2 MB choose the first partition large enough Next-fit similar to first-fit, but start searching from the last allocation process 6: 20 MB Relocation: memory addresses Relocation: MMU Logical (or virtual) address address generated by CPU Limit Base Physical address address sent to physical memory logical address + physical address >= MMU CPU Translation Memory logical address physical address MMU error (trap to OS) usually a component of the CPU

6 Memory partitioning Buddy system: example evolution Buddy system 1 MB block 100 KB request A=128 KB 128 KB 1 MB 512 KB memory: set of blocks of size S i =2 k (L k U) 240 KB request A=128 KB 128 KB B= 512 KB usually 2 U = memory size request: size=r looks for B i : best fit block (size = S=2 U ) 1. if 2 U-1 < R 2 U, allocate block 2. else split block in two sub-blocks of size 2 U-1 each 3. select one of the new blocks and repeat from step 1 release block of size 2 k if there are two adjacent blocks with same size, merge them 64 KB request A=128 KB C=64 KB 64 KB B= 512 KB request A=128 KB C=64 KB 64 KB B= D= release B release A A=128 KB C=64 KB 64 KB D= 128 KB C=64 KB 64 KB D= 75 KB request E=128 KB C=64 KB 64 KB D= release C E=128 KB 128 KB D= release E 512 KB D= release D 1 MB Buddy system: tree view Memory partitioning 1 MB 512 KB Segmentation Process images are divided into a number of segments. splitting is handled by programmer (or compiler). 128 KB 64 KB Load process load segments into dynamic partitions. Segments may be not contiguous. No internal fragmentation. Improved memory utilization. A=128 KB C=64 KB 64 KB D= if two buddies are leaf nodes: at least one is allocated otherwise: merge them Protection Sharing External fragmentation. Logical address to physical address translation.

7 Segmentation: example Segmentation: addresses translation Code-1 (main prg) Static Code-2 (library) Dynamic (heap) Stack Process image (logical address space) Dynamic (heap) Code-1 Static Code-2 OS maintains the list of free partitions Logical address <segment, offset> Translated through the process Segment Table logical address segment offset seg-0 limit seg-1 limit seg-2 limit seg-3 limit seg-0 other info seg-1 other info seg-2 other info seg-3 other info seg-0 base seg-1 base seg-2 base seg-3 base + physical address Stack Physical memory Segment table Segmentation: protection and sharing Segmentation: segment table example (IA-32) Code (private) Sdata (shared) LCode (library) Process A Segment table A process cannot access to a segment not pointed by its segment table Access to data/code segments can be restricted to valid operations Shared segments have identical entries in different segment tables Code (private) Sdata (shared) LCode (library) (private) Code Segment table Code (private) Sdata (shared) LCode (library) Process B BASE 31:24 G D / B L A V L LIMIT 19:16 P DPL B TYPE BASE 23: BASE 15:0 LIMIT 15:0 L: 64-bit code segment AVL: available for system software BASE: base address D/B: default operation size (16 (0) or 32 (1) bit) DPL: descriptor privilege level G: granularity LIMIT: segment size (bytes if G=0, 4KB pages if G=1) P: present S: type (0=system; 1=code or data) TYPE: segment type (data, code, stack, read/write,...) 64-bits segment descriptor-0 segment descriptor-1 segment descriptor-2 segment descriptor-3 segment descriptor-n Segment table

8 Memory partitioning Paging: example Paging Partition main memory into equal-size frames. Process images are divided into equal-size pages. Same length as frames. Load process load pages into available frames. Frames may be not contiguous. Not visible to programmer. No external fragmentation. A small amount of internal fragmentation. Logical address to physical address translation. Process A Process B P2 P3 P4 P5 P6 P2 P3 Memory P3 P3 P2 P2 P4 P6 P5 Frame-0 Frame-1 Frame-2 Frame-3 Frame-4 Frame-5 Frame-6 Frame-7 Frame-8 Frame-9 Frame-10 Frame-11 Frame-12 Frame-13 Frame-14 Frame-15 Frame-16 Frame-17 Contiguous pages map in non-contiguous, out of order frames Only the last page of a process can suffer of fragmentation (average wasted space = page-size/2) OS keeps the list of free pages (linked list or bitmap) Paging: address translation Logical address <page, offset> page: k bits ; page-size=2 k address: n bits max pages usable by a process=2 n-k Translated through the process Page Table logical address page # offset page-0 other info page-0 base page-1 other info page-1 base page-2 other info page-2 base page-3 other info page-3 base frame # offset physical address Page table other info: valid/non-valid, read-only/readwrite/executable, required privilege level,... Registers fast Paging: page table implementation limits the table size context switch overhead Memory more registers to save small context switch overhead slow only table pointer is kept in a register optionally the table length too each memory access requires additional memory accesses (to page table)

9 Paging: page table implementation Translation look-aside buffer (TLB) leverages the locality principle small cache with some page table entries the whole page table is in memory same tradeoffs of I/D caches miss rate, miss penalty, size, cost context switches cause the TLB flush logical address page # offset page # page info TLB frame # frame # offset physical address Paging: multilevel page tables Process A Process B P2 P3 P4 P5 P6 P2 P3 Paging: protection and sharing Memory P3 S P2 P4 P6 P5 Frame-0 Frame-1 Frame-2 Frame-3 Frame-4 Frame-5 Frame-6 Frame-7 Frame-8 Frame-9 Frame-10 Frame-11 Frame-12 Frame-13 Frame-14 Frame-15 Frame-16 Frame-17 Similarly to segmentation, A process cannot access to a page not pointed by its page table Access to data/code pages can be restricted to valid operations Shared pages have identical entries in different page tables Paging: inverted page table Address size: 32 or 64 bits too many entries in page table Multilevel page table not all the entries are actually stored ( paged page table) Inverted page table A single page table (no more one for process) One entry for each physical frame logical page address owning process information More logical pages can map on the same physical frame A linear search is not feasible search time: O(n) Implemented as hash table Multilevel page table search time (ideal): O(1) shared pages are handled as collisions

10 Paging: inverted page table Memory partitioning pid page# offset f offset Segmentation with paging search pid page# f Physical memory combined approach segments are divided into pages segment table contains Inverted page table logical linear base address for segment one page table for each process pid page# hash function Inverted page table: hash implementation offset f search pid page# f pid f page# offset IA-32 or pointer to page table one page table for each segment MULTICS Segmentation and paging example: IA-32 Segment Descriptor Table seg selector 16 bit seg register segment descriptor 32 bit offset access limit base address + 32-bits linear address dir page offset Physical address Virtual memory Logical address

11 Terms Keys Virtual memory Storage allocation scheme Secondary memory can be addressed as though it were part of main memory. Size of virtual storage limited by: the architecture addressing scheme the amount of secondary memory available not by the actual size of main memory Virtual address address assigned to a location in virtual memory that location is accessed as it were part of main memory Virtual address space Virtual storage assigned to a process. Address space Range of memory addresses available to a process. Real address Address of a location in main memory All memory references within a process are logical addresses dynamically translated into physical addresses at run time (mapping can change) a process may be swapped in and out of main memory it occupies different regions of main memory at different times A process may be broken up into a number of pieces contiguous allocation is not needed paging and/or segmentation All of the portions of a process in main memory during execution: not necessary portions can stay in secondary memory and be fetched when needed portions in main memory can be moved in secondary memory when space is needed Main memory swapping Secondary memory Virtual memory Process A portions Process B portions Locality and virtual memory On demanding paging Page fault rate Programs tend to use only a small subset of addresses in a time interval not all process image portions are needed at the same time current used portions: working set Page fault: access to a page not in main memory W: working set size Pages in main memory W Working set evolution stable stable transients stable stable Time Load a page in main memory only when needed CPU try to access a page not in main memory: page fault valid bit in page table signals if a page is in main memory (page valid) Fast process start Reduced memory usage allows higher multiprogramming degree Effective access time: EAT = 1 pt mem pt fault t mem p: page fault probability t mem : access time for a frame (typ.: 10ns) access to TLB access to page table access to memory t fault : time for handling page fault (typ.: 1ms)

12 Virtual memory access Page loading SW actions If there exist a free frame y CPU checks TLB found? n read page form disk load page else access page table page in main n memory? y trap: jump to OS routine memory full? page replacement select a victim frame modified? no: load page into selected frame update TLB yes: write frame in secondary memory and load page update page table a bit (dirty bit) is needed in page table generate physical address HW actions Page replacement policies Page replacement: FIFO Optimal minimizes page faults not realizable requires information on future accesses FIFO Least recently used (LRU) not recently used (NRU or clock ) First page loaded is the first swapped out does not take into account the page rank (rank: access rate) suffers of the Belady anomaly increasing the frames allocated for a process can increase page faults e.g. accesses: frames 9 page faults 4 frames 10 page faults Second chance

13 Page replacement: LRU Page replacement: NRU Select the page not accessed for the longest time very expensive to implement tag with access time stack with access sequence use approximation (NRU: not recently used) Add a bit (used bit) in page table set the used bit when a page is loaded or an access occurs select a frame with unset used bit for replacing scan the list in round robin fashion page table entries to avoid to victimize the same page too often reset used bits while searching variants: reset all used bits if a search fails reset all used bits after a frame is selected reset all used bits on a periodic scheduling Page replacement: second chance Page replacement Privilege dirty frames Comparison Algo 1 Algo 2 similar to NRU, but consider also the dirty bit first search: look for used=0, dirty=0 second search: look for used=0, dirty=1 third search: look for used=1, dirty=0 fourth search: look for used=1, dirty=1 used is cleared on a periodic schedule (timer interrupt) first search: look for used=0, dirty=0 second search: look for used=0, dirty=1 and clear every used bit checked third search: look for dirty=0 (all used bits are now 0) fourth search: look for dirty=1 Page faults per 1000 references Allocated frames

14 Frame allocation Frame allocation: fixed Fixed a process has a fixed number of frames allocated minimum number of frames: 1+max_addresses_accessible_by_a_single_instruction Variable process' frames can change over time Replacement scope local when a process needs a new page, free a frame of that process global search frames globally (not possible for fixed allocation) Equal each process has the same number of frames Size based a process has a number of frames proportional to its image size Other priority... Frame allocation: variable Frame allocation: trashing Working set based WS(t, ) = pages accessed in [t-,t] W = size of WS too small: not significative too big: too much pages Page fault based measure process' page fault rate W(t, ) below a threshold release frames above a threshold increase number of frames allocated Too few frames allocated to a process too much page faults: execution time bounded by swapping Can occur as a result of a wrong feedback process i has too few frames page fault process i is suspended CPU is less used execute a new process allocate frames new process removes frames to other processes other processes can suffer of thrashing throughput falls the whole system is working only in swapping pages

15 Frame allocation: trashing Page size Virtual memory: other considerations CPU usage trashing small little internal fragmentation many entries in page tables I/O overhead Program structure impact array: row scan multiprogramming degree Locked frames some frames must be kept in main memory kernel (at least a portion) security critical data array: column scan (can cause more page faults)

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses. 1 Memory Management Address Binding The normal procedures is to select one of the processes in the input queue and to load that process into memory. As the process executed, it accesses instructions and

More information

Memory Management. Reading: Silberschatz chapter 9 Reading: Stallings. chapter 7 EEL 358

Memory Management. Reading: Silberschatz chapter 9 Reading: Stallings. chapter 7 EEL 358 Memory Management Reading: Silberschatz chapter 9 Reading: Stallings chapter 7 1 Outline Background Issues in Memory Management Logical Vs Physical address, MMU Dynamic Loading Memory Partitioning Placement

More information

Chapter 8: Memory-Management Strategies

Chapter 8: Memory-Management Strategies Chapter 8: Memory-Management Strategies Chapter 8: Memory Management Strategies Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Example: The Intel 32 and

More information

Chapter 7: Main Memory. Operating System Concepts Essentials 8 th Edition

Chapter 7: Main Memory. Operating System Concepts Essentials 8 th Edition Chapter 7: Main Memory Operating System Concepts Essentials 8 th Edition Silberschatz, Galvin and Gagne 2011 Chapter 7: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure

More information

MEMORY MANAGEMENT/1 CS 409, FALL 2013

MEMORY MANAGEMENT/1 CS 409, FALL 2013 MEMORY MANAGEMENT Requirements: Relocation (to different memory areas) Protection (run time, usually implemented together with relocation) Sharing (and also protection) Logical organization Physical organization

More information

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1 Basic Memory Management Program must be brought into memory and placed within a process for it to be run Basic Memory Management CS 256/456 Dept. of Computer Science, University of Rochester Mono-programming

More information

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

CS6401- Operating System UNIT-III STORAGE MANAGEMENT UNIT-III STORAGE MANAGEMENT Memory Management: Background In general, to rum a program, it must be brought into memory. Input queue collection of processes on the disk that are waiting to be brought into

More information

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES OBJECTIVES Detailed description of various ways of organizing memory hardware Various memory-management techniques, including paging and segmentation To provide

More information

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Chapter 8 & Chapter 9 Main Memory & Virtual Memory Chapter 8 & Chapter 9 Main Memory & Virtual Memory 1. Various ways of organizing memory hardware. 2. Memory-management techniques: 1. Paging 2. Segmentation. Introduction Memory consists of a large array

More information

Chapter 8: Main Memory. Operating System Concepts 9 th Edition

Chapter 8: Main Memory. Operating System Concepts 9 th Edition Chapter 8: Main Memory Silberschatz, Galvin and Gagne 2013 Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Example: The Intel

More information

Chapter 8: Main Memory

Chapter 8: Main Memory Chapter 8: Main Memory Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Example: The Intel 32 and 64-bit Architectures Example:

More information

Chapter 8: Main Memory

Chapter 8: Main Memory Chapter 8: Main Memory Silberschatz, Galvin and Gagne 2013 Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Example: The Intel

More information

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference

More information

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

Performance of Various Levels of Storage. Movement between levels of storage hierarchy can be explicit or implicit Memory Management All data in memory before and after processing All instructions in memory in order to execute Memory management determines what is to be in memory Memory management activities Keeping

More information

Memory management. Last modified: Adaptation of Silberschatz, Galvin, Gagne slides for the textbook Applied Operating Systems Concepts

Memory management. Last modified: Adaptation of Silberschatz, Galvin, Gagne slides for the textbook Applied Operating Systems Concepts Memory management Last modified: 26.04.2016 1 Contents Background Logical and physical address spaces; address binding Overlaying, swapping Contiguous Memory Allocation Segmentation Paging Structure of

More information

Chapter 8 Memory Management

Chapter 8 Memory Management Chapter 8 Memory Management Da-Wei Chang CSIE.NCKU Source: Abraham Silberschatz, Peter B. Galvin, and Greg Gagne, "Operating System Concepts", 9th Edition, Wiley. 1 Outline Background Swapping Contiguous

More information

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science Virtual Memory CSCI 315 Operating Systems Design Department of Computer Science Notice: The slides for this lecture have been largely based on those from an earlier edition of the course text Operating

More information

CS399 New Beginnings. Jonathan Walpole

CS399 New Beginnings. Jonathan Walpole CS399 New Beginnings Jonathan Walpole Memory Management Memory Management Memory a linear array of bytes - Holds O.S. and programs (processes) - Each cell (byte) is named by a unique memory address Recall,

More information

Memory Management. Chapter 4 Memory Management. Multiprogramming with Fixed Partitions. Ideally programmers want memory that is.

Memory Management. Chapter 4 Memory Management. Multiprogramming with Fixed Partitions. Ideally programmers want memory that is. Chapter 4 Memory Management Ideally programmers want memory that is Memory Management large fast non volatile 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms

More information

Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1

Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1 Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1 Chapter 9: Memory Management Background Swapping Contiguous Memory Allocation Segmentation

More information

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition Chapter 8: Memory- Management Strategies Operating System Concepts 9 th Edition Silberschatz, Galvin and Gagne 2013 Chapter 8: Memory Management Strategies Background Swapping Contiguous Memory Allocation

More information

CS307: Operating Systems

CS307: Operating Systems CS307: Operating Systems Chentao Wu 吴晨涛 Associate Professor Dept. of Computer Science and Engineering Shanghai Jiao Tong University SEIEE Building 3-513 wuct@cs.sjtu.edu.cn Download Lectures ftp://public.sjtu.edu.cn

More information

12: Memory Management

12: Memory Management 12: Memory Management Mark Handley Address Binding Program goes through multiple steps from compilation to execution. At some stage, addresses in the program must be bound to physical memory addresses:

More information

Chapter 8: Memory Management. Operating System Concepts with Java 8 th Edition

Chapter 8: Memory Management. Operating System Concepts with Java 8 th Edition Chapter 8: Memory Management 8.1 Silberschatz, Galvin and Gagne 2009 Background Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are

More information

Memory Management. Memory Management

Memory Management. Memory Management Memory Management Gordon College Stephen Brinton Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 1 Background Program must be brought into memory

More information

Module 8: Memory Management

Module 8: Memory Management Module 8: Memory Management Background Logical versus Physical Address Space Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging Operating System Concepts 8.1 Silberschatz and Galvin

More information

Operating System Concepts

Operating System Concepts Chapter 9: Virtual-Memory Management 9.1 Silberschatz, Galvin and Gagne 2005 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped

More information

Basic Memory Management

Basic Memory Management Basic Memory Management CS 256/456 Dept. of Computer Science, University of Rochester 10/15/14 CSC 2/456 1 Basic Memory Management Program must be brought into memory and placed within a process for it

More information

Main Memory (Part I)

Main Memory (Part I) Main Memory (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir H. Payberah (Tehran Polytechnic) Main Memory 1393/8/5 1 / 47 Motivation and Background Amir

More information

Chapter 8 Virtual Memory

Chapter 8 Virtual Memory Chapter 8 Virtual Memory Contents Hardware and control structures Operating system software Unix and Solaris memory management Linux memory management Windows 2000 memory management Characteristics of

More information

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access)

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access) Virtual Memory - programmer views memory as large address space without concerns about the amount of physical memory or memory management. (What do the terms 3-bit (or 6-bit) operating system or overlays

More information

CHAPTER 8: MEMORY MANAGEMENT. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

CHAPTER 8: MEMORY MANAGEMENT. By I-Chen Lin Textbook: Operating System Concepts 9th Ed. CHAPTER 8: MEMORY MANAGEMENT By I-Chen Lin Textbook: Operating System Concepts 9th Ed. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the

More information

CS450/550 Operating Systems

CS450/550 Operating Systems CS450/550 Operating Systems Lecture 4 memory Palden Lama Department of Computer Science CS450/550 Memory.1 Review: Summary of Chapter 3 Deadlocks and its modeling Deadlock detection Deadlock recovery Deadlock

More information

Chapter 9 Memory Management

Chapter 9 Memory Management Contents 1. Introduction 2. Computer-System Structures 3. Operating-System Structures 4. Processes 5. Threads 6. CPU Scheduling 7. Process Synchronization 8. Deadlocks 9. Memory Management 10. Virtual

More information

Background. Contiguous Memory Allocation

Background. Contiguous Memory Allocation Operating System Lecture 8 2017.5.9 Chapter 8 (Main Memory) Background Swapping Contiguous Memory Allocation Segmentation - Paging Memory Management Selection of a memory-management method for a specific

More information

Chapter 4 Memory Management

Chapter 4 Memory Management Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms 4.6 Design issues for paging systems 4.7

More information

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective Part I: Operating system overview: Memory Management 1 Hardware background The role of primary memory Program

More information

Operating Systems Memory Management. Mathieu Delalandre University of Tours, Tours city, France

Operating Systems Memory Management. Mathieu Delalandre University of Tours, Tours city, France Operating Systems Memory Management Mathieu Delalandre University of Tours, Tours city, France mathieu.delalandre@univ-tours.fr 1 Operating Systems Memory Management 1. Introduction 2. Contiguous memory

More information

Operating Systems. 09. Memory Management Part 1. Paul Krzyzanowski. Rutgers University. Spring 2015

Operating Systems. 09. Memory Management Part 1. Paul Krzyzanowski. Rutgers University. Spring 2015 Operating Systems 09. Memory Management Part 1 Paul Krzyzanowski Rutgers University Spring 2015 March 9, 2015 2014-2015 Paul Krzyzanowski 1 CPU Access to Memory The CPU reads instructions and reads/write

More information

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory Chapter 9: Virtual Memory Chapter 9: Virtual Memory 9.1 Background 9.2 Demand Paging 9.3 Copy-on-Write 9.4 Page Replacement 9.5 Allocation of Frames 9.6 Thrashing 9.7 Memory-Mapped Files 9.8 Allocating

More information

Chapters 9 & 10: Memory Management and Virtual Memory

Chapters 9 & 10: Memory Management and Virtual Memory Chapters 9 & 10: Memory Management and Virtual Memory Important concepts (for final, projects, papers) addressing: physical/absolute, logical/relative/virtual overlays swapping and paging memory protection

More information

The Virtual Memory Abstraction. Memory Management. Address spaces: Physical and Virtual. Address Translation

The Virtual Memory Abstraction. Memory Management. Address spaces: Physical and Virtual. Address Translation The Virtual Memory Abstraction Memory Management Physical Memory Unprotected address space Limited size Shared physical frames Easy to share data Virtual Memory Programs are isolated Arbitrary size All

More information

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition Chapter 8: Memory- Management Strategies Operating System Concepts 9 th Edition Silberschatz, Galvin and Gagne 2013 Chapter 8: Memory Management Strategies Background Swapping Contiguous Memory Allocation

More information

Chapter 8: Memory- Management Strategies

Chapter 8: Memory- Management Strategies Chapter 8: Memory Management Strategies Chapter 8: Memory- Management Strategies Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Example: The Intel 32 and

More information

Chapter 8 Main Memory

Chapter 8 Main Memory COP 4610: Introduction to Operating Systems (Spring 2014) Chapter 8 Main Memory Zhi Wang Florida State University Contents Background Swapping Contiguous memory allocation Paging Segmentation OS examples

More information

Move back and forth between memory and disk. Memory Hierarchy. Two Classes. Don t

Move back and forth between memory and disk. Memory Hierarchy. Two Classes. Don t Memory Management Ch. 3 Memory Hierarchy Cache RAM Disk Compromise between speed and cost. Hardware manages the cache. OS has to manage disk. Memory Manager Memory Hierarchy Cache CPU Main Swap Area Memory

More information

Memory Management Ch. 3

Memory Management Ch. 3 Memory Management Ch. 3 Ë ¾¾ Ì Ï ÒÒØ Å ÔÔ ÓÐÐ 1 Memory Hierarchy Cache RAM Disk Compromise between speed and cost. Hardware manages the cache. OS has to manage disk. Memory Manager Ë ¾¾ Ì Ï ÒÒØ Å ÔÔ ÓÐÐ

More information

a process may be swapped in and out of main memory such that it occupies different regions

a process may be swapped in and out of main memory such that it occupies different regions Virtual Memory Characteristics of Paging and Segmentation A process may be broken up into pieces (pages or segments) that do not need to be located contiguously in main memory Memory references are dynamically

More information

Memory management: outline

Memory management: outline Memory management: outline Concepts Swapping Paging o Multi-level paging o TLB & inverted page tables 1 Memory size/requirements are growing 1951: the UNIVAC computer: 1000 72-bit words! 1971: the Cray

More information

Memory management: outline

Memory management: outline Memory management: outline Concepts Swapping Paging o Multi-level paging o TLB & inverted page tables 1 Memory size/requirements are growing 1951: the UNIVAC computer: 1000 72-bit words! 1971: the Cray

More information

Chapter 4 Memory Management. Memory Management

Chapter 4 Memory Management. Memory Management Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms 4.6 Design issues for paging systems 4.7

More information

Logical versus Physical Address Space

Logical versus Physical Address Space CHAPTER 8: MEMORY MANAGEMENT Background Logical versus Physical Address Space Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging Operating System Concepts, Addison-Wesley 1994

More information

File Systems. OS Overview I/O. Swap. Management. Operations CPU. Hard Drive. Management. Memory. Hard Drive. CSI3131 Topics. Structure.

File Systems. OS Overview I/O. Swap. Management. Operations CPU. Hard Drive. Management. Memory. Hard Drive. CSI3131 Topics. Structure. File Systems I/O Management Hard Drive Management Virtual Memory Swap Memory Management Storage and I/O Introduction CSI3131 Topics Process Management Computing Systems Memory CPU Peripherals Processes

More information

Chapter 8: Virtual Memory. Operating System Concepts

Chapter 8: Virtual Memory. Operating System Concepts Chapter 8: Virtual Memory Silberschatz, Galvin and Gagne 2009 Chapter 8: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating

More information

Part Three - Memory Management. Chapter 8: Memory-Management Strategies

Part Three - Memory Management. Chapter 8: Memory-Management Strategies Part Three - Memory Management Chapter 8: Memory-Management Strategies Chapter 8: Memory-Management Strategies 8.1 Background 8.2 Swapping 8.3 Contiguous Memory Allocation 8.4 Segmentation 8.5 Paging 8.6

More information

Memory Management. Contents: Memory Management. How to generate code? Background

Memory Management. Contents: Memory Management. How to generate code? Background TDIU11 Operating systems Contents: Memory Management Memory Management [SGG7/8/9] Chapter 8 Background Relocation Dynamic loading and linking Swapping Contiguous Allocation Paging Segmentation Copyright

More information

Chapter 8: Main Memory

Chapter 8: Main Memory Chapter 8: Main Memory Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium 8.2 Silberschatz, Galvin

More information

Memory Management and Protection

Memory Management and Protection Part IV Memory Management and Protection Sadeghi, Cubaleska RUB 2008-09 Course Operating System Security Memory Management and Protection Main Memory Virtual Memory Roadmap of Chapter 4 Main Memory Background

More information

8.1 Background. Part Four - Memory Management. Chapter 8: Memory-Management Management Strategies. Chapter 8: Memory Management

8.1 Background. Part Four - Memory Management. Chapter 8: Memory-Management Management Strategies. Chapter 8: Memory Management Part Four - Memory Management 8.1 Background Chapter 8: Memory-Management Management Strategies Program must be brought into memory and placed within a process for it to be run Input queue collection of

More information

6 - Main Memory EECE 315 (101) ECE UBC 2013 W2

6 - Main Memory EECE 315 (101) ECE UBC 2013 W2 6 - Main Memory EECE 315 (101) ECE UBC 2013 W2 Acknowledgement: This set of slides is partly based on the PPTs provided by the Wiley s companion website (including textbook images, when not explicitly

More information

Virtual Memory Outline

Virtual Memory Outline Virtual Memory Outline Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations Operating-System Examples

More information

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management CSE 120 July 18, 2006 Day 5 Memory Instructor: Neil Rhodes Translation Lookaside Buffer (TLB) Implemented in Hardware Cache to map virtual page numbers to page frame Associative memory: HW looks up in

More information

Chapter 8: Main Memory. Operating System Concepts 8th Edition

Chapter 8: Main Memory. Operating System Concepts 8th Edition Chapter 8: Main Memory Operating System Concepts 8th Edition Silberschatz, Galvin and Gagne 2009 Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page

More information

Module 8: Memory Management

Module 8: Memory Management Module 8: Memory Management Background Logical versus Physical Address Space Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 8.1 Background Program must be brought into memory

More information

Module 9: Memory Management. Background. Binding of Instructions and Data to Memory

Module 9: Memory Management. Background. Binding of Instructions and Data to Memory Module 9: Memory Management Background Logical versus Physical Address Space Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 9.1 Background Program must be brought into memory

More information

Chapter 8: Main Memory

Chapter 8: Main Memory Chapter 8: Main Memory Operating System Concepts 8 th Edition,! Silberschatz, Galvin and Gagne 2009! Chapter 8: Memory Management Background" Swapping " Contiguous Memory Allocation" Paging" Structure

More information

Memory Management. CSCI 315 Operating Systems Design Department of Computer Science

Memory Management. CSCI 315 Operating Systems Design Department of Computer Science Memory Management CSCI 315 Operating Systems Design Department of Computer Science Notice: The slides for this lecture are based on those from Operating Systems Concepts, 9th ed., by Silberschatz, Galvin,

More information

Operating Systems. Overview Virtual memory part 2. Page replacement algorithms. Lecture 7 Memory management 3: Virtual memory

Operating Systems. Overview Virtual memory part 2. Page replacement algorithms. Lecture 7 Memory management 3: Virtual memory Operating Systems Lecture 7 Memory management : Virtual memory Overview Virtual memory part Page replacement algorithms Frame allocation Thrashing Other considerations Memory over-allocation Efficient

More information

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others Memory Management 1 Learning Outcomes Appreciate the need for memory management in operating systems, understand the limits of fixed memory allocation schemes. Understand fragmentation in dynamic memory

More information

Chapter 8: Memory Management

Chapter 8: Memory Management Chapter 8: Memory Management Chapter 8: Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 8.2 Background Program must be brought into memory and placed

More information

Motivation. Memory Management. Memory Management. Computer Hardware Review

Motivation. Memory Management. Memory Management. Computer Hardware Review Memory Management Motivation Vera Goebel Department of Informatics, University of Oslo with slides from: C. Griwodz (Ifi/UiO), P. Halvorsen (Ifi/UiO), K. Li (Princeton), A. Tanenbaum (VU Amsterdam), and

More information

Module 9: Virtual Memory

Module 9: Virtual Memory Module 9: Virtual Memory Background Demand Paging Performance of Demand Paging Page Replacement Page-Replacement Algorithms Allocation of Frames Thrashing Other Considerations Demand Segmentation Operating

More information

Chapter 7 Memory Management

Chapter 7 Memory Management Operating Systems: Internals and Design Principles Chapter 7 Memory Management Ninth Edition William Stallings Frame Page Segment A fixed-length block of main memory. A fixed-length block of data that

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 2018 L17 Main Memory Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Was Great Dijkstra a magician?

More information

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory Chapter 9: Virtual Memory Background Demand Paging Chapter 9: Virtual Memory Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations

More information

Module 9: Virtual Memory

Module 9: Virtual Memory Module 9: Virtual Memory Background Demand Paging Performance of Demand Paging Page Replacement Page-Replacement Algorithms Allocation of Frames Thrashing Other Considerations Demand Segmenation 9.1 Background

More information

Chapter 9: Virtual-Memory

Chapter 9: Virtual-Memory Chapter 9: Virtual-Memory Management Chapter 9: Virtual-Memory Management Background Demand Paging Page Replacement Allocation of Frames Thrashing Other Considerations Silberschatz, Galvin and Gagne 2013

More information

Operating Systems Lecture 6: Memory Management II

Operating Systems Lecture 6: Memory Management II CSCI-GA.2250-001 Operating Systems Lecture 6: Memory Management II Hubertus Franke frankeh@cims.nyu.edu What is the problem? Not enough memory Have enough memory is not possible with current technology

More information

Chapter 9: Memory Management. Background

Chapter 9: Memory Management. Background 1 Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 9.1 Background Program must be brought into memory and placed within a process for

More information

Memory Management. Memory Management

Memory Management. Memory Management Memory Management Most demanding di aspect of an operating system Cost has dropped. Consequently size of main memory has expanded enormously. Can we say that we have enough still. Swapping in/out. Memory

More information

CISC 7310X. C08: Virtual Memory. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/22/2018 CUNY Brooklyn College

CISC 7310X. C08: Virtual Memory. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/22/2018 CUNY Brooklyn College CISC 7310X C08: Virtual Memory Hui Chen Department of Computer & Information Science CUNY Brooklyn College 3/22/2018 CUNY Brooklyn College 1 Outline Concepts of virtual address space, paging, virtual page,

More information

Process. One or more threads of execution Resources required for execution

Process. One or more threads of execution Resources required for execution Memory Management 1 Learning Outcomes Appreciate the need for memory management in operating systems, understand the limits of fixed memory allocation schemes. Understand fragmentation in dynamic memory

More information

Topics: Memory Management (SGG, Chapter 08) 8.1, 8.2, 8.3, 8.5, 8.6 CS 3733 Operating Systems

Topics: Memory Management (SGG, Chapter 08) 8.1, 8.2, 8.3, 8.5, 8.6 CS 3733 Operating Systems Topics: Memory Management (SGG, Chapter 08) 8.1, 8.2, 8.3, 8.5, 8.6 CS 3733 Operating Systems Instructor: Dr. Turgay Korkmaz Department Computer Science The University of Texas at San Antonio Office: NPB

More information

CS 5523 Operating Systems: Memory Management (SGG-8)

CS 5523 Operating Systems: Memory Management (SGG-8) CS 5523 Operating Systems: Memory Management (SGG-8) Instructor: Dr Tongping Liu Thank Dr Dakai Zhu, Dr Palden Lama, and Dr Tim Richards (UMASS) for providing their slides Outline Simple memory management:

More information

Goals of Memory Management

Goals of Memory Management Memory Management Goals of Memory Management Allocate available memory efficiently to multiple processes Main functions Allocate memory to processes when needed Keep track of what memory is used and what

More information

Preview. Memory Management

Preview. Memory Management Preview Memory Management With Mono-Process With Multi-Processes Multi-process with Fixed Partitions Modeling Multiprogramming Swapping Memory Management with Bitmaps Memory Management with Free-List Virtual

More information

Operating System 1 (ECS-501)

Operating System 1 (ECS-501) Operating System 1 (ECS-501) Unit- IV Memory Management 1.1 Bare Machine: 1.1.1 Introduction: It has the ability to recover the operating system of a machine to the identical state it was at a given point

More information

Virtual Memory COMPSCI 386

Virtual Memory COMPSCI 386 Virtual Memory COMPSCI 386 Motivation An instruction to be executed must be in physical memory, but there may not be enough space for all ready processes. Typically the entire program is not needed. Exception

More information

Memory Management. Dr. Yingwu Zhu

Memory Management. Dr. Yingwu Zhu Memory Management Dr. Yingwu Zhu Big picture Main memory is a resource A process/thread is being executing, the instructions & data must be in memory Assumption: Main memory is infinite Allocation of memory

More information

1. Background. 2. Demand Paging

1. Background. 2. Demand Paging COSC4740-01 Operating Systems Design, Fall 2001, Byunggu Yu Chapter 10 Virtual Memory 1. Background PROBLEM: The entire process must be loaded into the memory to execute limits the size of a process (it

More information

CS420: Operating Systems

CS420: Operating Systems Main Memory James Moscola Department of Engineering & Computer Science York College of Pennsylvania Based on Operating System Concepts, 9th Edition by Silberschatz, Galvin, Gagne Background Program must

More information

Chapter 9: Virtual Memory. Chapter 9: Virtual Memory. Objectives. Background. Virtual-address address Space

Chapter 9: Virtual Memory. Chapter 9: Virtual Memory. Objectives. Background. Virtual-address address Space Chapter 9: Virtual Memory Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations

More information

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory Chapter 9: Virtual Memory Multiprogramming Memory Management so far 1. Dynamic Loading The main Program gets loaded into memory Routines are stored in Relocatable Load format on disk As main program (or

More information

Outlook. Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium

Outlook. Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium Main Memory Outlook Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium 2 Backgound Background So far we considered how to share

More information

Memory Management Virtual Memory

Memory Management Virtual Memory Background; key issues Memory Management Virtual Memory Memory allocation schemes Virtual memory Memory management design and implementation issues 1 Remember Basic OS structures: intro in historical order

More information

Main Memory. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & APPS 1

Main Memory. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & APPS 1 Main Memory Electrical and Computer Engineering Stephen Kim (dskim@iupui.edu) ECE/IUPUI RTOS & APPS 1 Main Memory Background Swapping Contiguous allocation Paging Segmentation Segmentation with paging

More information

Chapter 8: Memory Management Strategies

Chapter 8: Memory Management Strategies Chapter 8: Memory- Management Strategies, Silberschatz, Galvin and Gagne 2009 Chapter 8: Memory Management Strategies Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table

More information

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory Chapter 9: Virtual Memory Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations

More information

Memory Management Cache Base and Limit Registers base limit Binding of Instructions and Data to Memory Compile time absolute code Load time

Memory Management Cache Base and Limit Registers base limit Binding of Instructions and Data to Memory Compile time absolute code Load time Memory Management To provide a detailed description of various ways of organizing memory hardware To discuss various memory-management techniques, including paging and segmentation To provide a detailed

More information

Operating Systems. Memory Management. Lecture 9 Michael O Boyle

Operating Systems. Memory Management. Lecture 9 Michael O Boyle Operating Systems Memory Management Lecture 9 Michael O Boyle 1 Memory Management Background Logical/Virtual Address Space vs Physical Address Space Swapping Contiguous Memory Allocation Segmentation Goals

More information