Chapters 7-8. Memory Management. Chapter 7 - Physical Memory. 7.1 Preparing a Program for Execution

Size: px
Start display at page:

Download "Chapters 7-8. Memory Management. Chapter 7 - Physical Memory. 7.1 Preparing a Program for Execution"

Transcription

1 Chapters 7-8 Memory Management Real memory Logical storage Address spaces Virtual memory 1 Chapter 7 - Physical Memory 71 Preparing a Program for Execution Program Transformations Logical-to-Physical Address Binding 72 Memory Partitioning Schemes Fixed Partitions Variable Partitions 73 Allocation Strategies for Variable Partitions 74 Dealing with Insufficient Memory 2

2 8 Virtual Memory 81 Principles of Virtual Memory 82 Implementations of Virtual Memory Paging Segmentation Paging With Segmentation Paging of System Tables Translation Look-aside Buffers 83 Memory Allocation in Paged Systems Global Page Replacement Algorithms Local Page Replacement Algorithms Load Control and Thrashing Evaluation of Paging 3 Address Binding Time assign physical addresses = relocation static binding programming time compilation time linking time loading time dynamic binding execution time 4

3 Relocation Assignment of real memory Programs make use of logical address space Code/Data spaces Segments Real memory is linear divided into segments subdivided into page frames Relocation - Load Static (link bind early) Dynamic (link bind late) Hardware supported MMU and HW caches 5 Fig 7-3a: storage reference with dynamic relocation (general principle) NL_map: {relocatable (virtual) addresses} {real (physical) storage addresses} CPU logical address Address Relocation NL_map physical address Main storage Data transfer (read/write) MMU I/O subsystem 6

4 Address binding how to implement dynamic binding perform for each address at run time: pa = address_map(la) la == va pa = F ( va ) simplest form of address_map function: relocation register pa = la + RR more general form: page/segment table (Chapter 8) 7 Partitions - Segments Multiprogramming requires that more than one program is kept in main memory Memory is divided into logical partitions Partitions can be of fixed or variable size and be located at specific or selectable locations - segments Each partitions should provide a private address space for the program/process/thread/object Efficient partition management and address binding requires hardware support Segments (base and limit registers) and Page Frames with appropriate relocation support must alleviate this task of the operating system 8

5 logical (virtual) memory VM_1 physical (real) memory NL_map VM_2 segmented memory flexible logical address management 9 Drawbacks Address translation at run time consumes time (TINSTAAFL) there is no such thing as afree lunch Programs and data areas grow and shrink dynamically in size Partitions are eventually released (freed by a program) Newly arriving processes require memory space Ie allocation of a partition Need to manage free space and allocation of partitions Possibly rearrange dynamically the allocation 10

6 D > H 1, D > H 2 D < H 1 + H 2 Memory fragmentation A A B H 2 D C C H 1 H 1 D 11 memory compaction p 1 initial state 2 3 p 1 total compaction 3 p 2 2 p 1 p 2 partial compaction 3 2 p 2 p 1 minimal move p 3 5 p p 3 5 p 3 5 p

7 Address Space Management Programs have a dynamic calling structure subroutines, procedures, functions etc Programs also frequently have varying data areas A programmer may not know how his/her program behaves Measurements have shown that statistically programs tend to exhibit high locality Using this characteristic feature one can delegate the management of the mapping from logical ( virtual ) addresses to real, physical addresses to a combination of hardware and software (operating system) Hence, the user is presented with the illusion of an almost unlimited, private address space! 13 logical (virtual) memory VM_1 page 0 page 1 page 2 VM_2 NL_map physical (real) memory frame 0 frame 1 frame 2 frame 3 page x frame 4 frame 5 frame 6 frame 7 pages MMU page frames paged memory flexible physical address management 14

8 paging The physical memory is subdivided into page frames The logical memory is subdivided into pages This means that memory addresses are now composed of two parts: A page number An offset (distance) within the page Hardware assistance is required for the binding: Page numbers are translated into frame numbers The offset value is used as is Attention: this is not identical to virtual memory!!! 15 p bits w bits va page number p w f bits w bits pa frame number f w Fig 8-2: form of virtual and physical address 16

9 Page No NS - virtual memory LS - physical memory Frame No 0 NL_map (p,w) (f,w) f F-1 P-1 Fig 8-3: paged virtual memory 17 Principles of virtual memory system creates illusion of large contiguous memory space(s) for each process relevant portions of VM are loaded automatically and transparently address map translates virtual addresses to physical addresses Figure

10 logical (virtual) memory VM_1 physical (real) memory NL_map VM_2 Fig 8-1: principles of virtual memory 19 Principles of virtual memory single-segment VM: one area of 0n-1 words divided into fix-size pages multiple-segment VM: multiple areas of up to 0n-1 (words) each holds a logical segment (function, data structure) each is contiguous or divided into pages 20

11 address mapping Main issues in VM design how to translate virtual addresses to physical placement where to place a portion of VM needed by process replacement which portion of VM to remove when space is needed load control how much of VM to load at any one time sharing how can processes share portions of their VMs 21 Implementation using paging VM is divided into fix-size pages PM is divided into page frames (page size) system loads pages into frames and translates addresses virtual address: va = (p,w) physical address: pa = (f,w) p determines number of pages in VM f determines number of frames in PM w determines page/frame size Figure

12 given (p,w): Address translation determine f from p -- how to keep track? concatenate f+w to form pa one solution: frame table one entry FT[i] for each frame FT[i]pid records process ID FT[i]page records page number p given (id,p,w): search for a match on (id,p): index f is the frame number 23 logical / virtual memory pid = 1 frame table physical memory pid = pid = 1 (p) (f,w) (p,w) pid = 2 (p) (p,w) 00F F FFF F = inverted page table 24

13 Address translation address map(id, p, w) { } pa = UNDEFINED; for (f = 0; f < F; f++) if (FT[f]pid==id && FT[f]page==p) pa:= (f+w); return pa; f F-1 Frame table Id pid Id p p FT page w distance frame address pages in main memory w frame f page p memory access Fig 8-4: address translation with frame 26 table

14 Address translation Figure 8-4 address_map(id, p, w) { pa = UNDEFINED; for (f = 0; f < F; f++) if (FT[f]pid==id && FT[f]page==p) pa = f+w; return pa; } drawbacks of frame table implementation costly: search must be done in parallel in hardware sharing of pages difficult or not possible 27 Page tables PT associated with each VM (not PM) PTR points at PT at run time p th entry holds frame number of page p: *(PTR+p) points to frame f address translation: address_map(p, w) { pa = *(PTR+p)+w; return pa } Figure 8-5 drawback: extra memory access 28

15 logical / virtual memory pid = 1 (p) physical memory pid = (f,w) (p,w) (f) (p,w) (f) 00F F FFF F page table page table 29 page tables p w distance pages in main memory PTR p f frame address w memory access Fig 8-5: address translation with page 30 table

16 PTR = 1024 va = pa = 3172 Fig 8-6: page table contents 31 0 page no Associative memory p w distance pages in main memory i F-1 parallel search page in Frame_i frame address w memory access Fig 8-?: address translation with page 32 table

17 Address Mapping Two possible approaches: Frame table 1 entry per real page frame Page table 1 entry per logical/virtual page Both solutions depend on searching the table Requires hardware support to speed up the process (associative memory Translation Lookaside Buffer) Both solutions need 2 memory accesses per memory reference unless associative memory is used for the translation table 33 Demand paging all pages of VM can be loaded initially simple but maximum size of VM = size of PM pages a loaded as needed -- on demand additional bit in PT indicates presence/absence page fault occurs when page is absent address_map(p, w) { if (resident(*(ptr+p))) { pa = *(PTR+p)+w; return pa; } else page_fault; } 34

18 VM using segmentation multiple contiguous spaces more natural match to program/data structure easier sharing (Chapter 9) va = (s,w) mapped to pa (but no frames) where/how are segments placed in PM? contiguous versus paged application 35 Contiguous allocation each segment is contiguous in PM ST keeps track of starting locations STR point to ST address translation address_map(s, w) { if (resident(*(str+s))) { pa = *(STR+s)+w; return pa; } else segment_fault; } drawback: external fragmentation 36

19 Paging with segmentation each segment is divided into fix-size pages va = (s,p,w) s determines # of segments (size of ST) p determines # of pages per seg (size of PT) w determines page size pa = *(*(STR+s)+p)+w Figure 8-7 drawback: 2 extra memory references 37 segment no s p w segment table page tables memory pages STR s p w Fig 8-7: address translation with page and segment 38 table

20 Paging of system tables ST or PT may be too large to keep in PM divide ST or PT into pages keep track by additional page table paging of ST ST divided into pages segment directory keeps track of ST pages va = (s1,s2,p,w) pa = *(*(*(STR+s1)+s2)+p)+w Figure s 1 s 2 p w paged segment tables page table memory pages STR s 1 s 2 p w Fig 8-8: address translation with paged segment 40table

21 14 32 s offset segment table segment segment registers s base 32 offset 32 Fig 8-9a: address translation in the Pentium processor segmentation only s offset p1 p2 w segment table s segment registers base 32 p1 p2 w page directory Fig 8-9b: address translation in the Pentium processor segmentation with CS paging 325 pages of page table program /data pages 42

22 Translation look-aside buffers to avoid additional memory accesses keep most recently translated page numbers in associative memory: for any (s,p,*) keep (s,p) and frame# f bypass translation if match on (s,p) found Figure 8-10 TLB is different from cache TLB only keeps frame #s cache keeps data values 43 s p w pages in main memory w replacement info (LRU) s, p segment/page number f frame number Fig 8-10: translation lookaside 44buffer

23 Memory allocation with paging placement policy: any free frame is ok replacement: must minimize data movement global replacement: consider all resident pages (regardless of owner) local replacement consider only pages of faulting process how to compare different algorithms: use reference string: r 0 r 1 r t r t is the number of the page referenced at time t count # of page faults 45 Global page replacement optimal (MIN): replace page that will not be referenced for the longest time in the future Time t RS c a d b e b a b c d Frame 0 a a a a a a a a a a d Frame 1 b b b b b b b b b b b Frame 2 c c c c c c c c c c c Frame 3 d d d d d e e e e e e IN e d OUT d a problem: RS not known in advance 46

24 random replacement Global page replacement simple but does not exploit the locality of reference most instructions are sequential (branch instructions typically,<~10%) most loops are short (within at most a few pages) many data structures are accessed sequentially (but overall arrangements can be critical - "wrap around" for column/row access - phased bank structure) 47 Global page replacement FIFO: replace oldest page Time t RS c a d b e b a b c d Frame 0 >a >a >a >a >a e e e e >e d Frame 1 b b b b b >b >b a a a >a Frame 2 c c c c c c c >c b b b Frame 3 d d d d d d d d >d c c IN e a b c d OUT a b c d e problem: favors recently accessed pages but ignores when program returns to old pages 48

25 Global page replacement LRU: replace least recently used page Time t RS c a d b e b a b c d Frame 0 a a a a a a a a a a d Frame 1 b b b b b b b b b b b Frame 2 c c c c c e e e e e d Frame 3 d d d d d d d d d c c IN e c d OUT c d e Qend d c a d b e b a b c d c d c a d b e b a b c b b d c a d d e e a b Qhead a a b b c a a d d e a 49 Global page replacement LRU implementation software queue: too expensive time-stamping stamp each referenced page with current time replace page with oldest stamp hardware capacitor with each frame charge at reference replace page with smallest charge n-bit aging register with each frame shift all registers to right at every reference set left-most bit of referenced page to 1 replace page with smallest value 50

26 Global page replacement second-chance algorithm approximates LRU implement use-bit u with each frame u=1 when page referenced to select a page: if u==0, select page else, set u=0 and consider next frame used page gets a second chance to stay in PM algorithm is called clock algorithm: search cycles through page frames 51 Global page replacement second-chance algorithm b e b a b c d >a/1 e/1 e/1 e/1 e/1 >e/1 d/1 b/1 >b/0 >b/1 b/0 b/1 b/1 >b/0 c/1 c/0 c/0 a/1 a/1 a/1 a/0 d/1 d/0 d/0 >d/0 >d/0 c/1 c/0 e a c d 52

27 Global page replacement third-chance algorithm second chance makes no difference between read and write access write access more expensive give modified pages a third chance: u-bit set at every reference (read and write) w-bit set at write reference to select a page, cycle through frames, resetting bits, until uw==00: uw uw "cheapest" candidate (cached?) * (remember modification) 0 0 select 53 Global page replacement third-chance algorithm c a w d b w e >a/10 >a/10 >a/11 >a/11 >a/11 a/00* b/10 b/10 b/10 b/10 b/11 b/00* c/10 c/10 c/10 c/10 c/10 e/10 d/10 d/10 d/10 d/10 d/10 >d/00 e 54

28 Local page replacement measurements indicate that every program needs a minimum set of pages if too few, thrashing occurs if too many, page frames are wasted the minimum varies over time how to determine and implement this minimum? 55 Local page replacement optimal (VMIN) define a sliding window (t,t+τ) τ is a parameter (constant) at any time t, maintain as resident all pages visible in window guaranteed to generate smallest number of page faults 56

29 Local page replacement optimal (VMIN) with τ=3 Time t RS d c c d b c e c e a d Page a Page b Page c Page d Page e IN c b e a d OUT d b c e a guaranteed optimal but unrealizable without RS 57 Local page replacement working set model: use principle of locality use trailing window (instead of future window) working set W(t,τ): all pages referenced during (t τ,t) at time t: remove all pages not in W(t,τ) process may run only if entire W(t,τ) is resident 58

30 Local page replacement working set model Time t RS a c c d b c e c e a d Page a Page b Page c - Page d Page e IN c b e a d OUT e a d b drawback: costly to implement approximate (aging registers, time stamps) 59 Local page replacement page fault frequency main objective: keep page fault rate low basic principle of pff: if time between page faults τ, grow resident set: add new page to resident set if time between page faults > τ, shrink resident set: add new page but remove all pages not referenced since last page fault 60

31 page fault frequency Local page replacement Time t RS c c d b c e c e a d Page a v Page b Page c - Page d - v Page e v v - - IN c b e a d OUT ae bd 61 Load control and thrashing main issues: how to choose degree of multiprogramming when level decreased, which process should be deactivated when new process reactivated, which of its pages should be loaded 62

32 Load control and thrashing choosing degree of multiprogramming local replacement: working set of any process must be resident this automatically imposes a limit global replacement no working set concept use CPU utilization as a criterion with too many processes, thrashing occurs Figure L >> S Fig 8-11: program behavior L ~ S L < S degree of multiprogramming 64

33 Load control and thrashing how to find N max? L=S criterion: page fault service S needs to keep up with mean time between faults L 50% criterion: CPU utilization is highest when paging disk ~50% busy (found experimentally) 65 Load control and thrashing which process to deactivate lowest priority process faulting process last process activated smallest process largest process which pages to load when process activated Figure 8-12 > prepage last resident set 66

34 Fig 8-12: lifetime curve of a program page fault rate decreases, MTBPF grows slowly - > adding pages has small benefits page fault rate increases & MTBPF also -> prepage size frequent page faults 67 Evaluation of paging experimental measurements: Figure 8-13 (a): number of pages referenced over time initial set can be loaded more efficiently than by individual page faults (b): number of instructions executed within one page (c): influence of page size for fixed total on page fault rate (d): influence of available number of pages on page fault rate 68

35 Fig 8-13: qualitative behavior 69 Conclusions (a): prepaging is important initial set can be loaded more efficiently than by individual page faults (b,c): suggest page size should be small, however, small pages require larger page tables more hardware greater I/O overhead (d): load control algorithm is important 70

Operating Systems (2INC0) 2017/18

Operating Systems (2INC0) 2017/18 Operating Systems (2INC0) 2017/18 Virtual Memory (10) Dr Courtesy of Dr I Radovanovic, Dr R Mak System rchitecture and Networking Group genda Recap memory management in early systems Principles of virtual

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

Chapter 8. Virtual Memory

Chapter 8. Virtual Memory Operating System Chapter 8. Virtual Memory Lynn Choi School of Electrical Engineering Motivated by Memory Hierarchy Principles of Locality Speed vs. size vs. cost tradeoff Locality principle Spatial Locality:

More information

Memory Management. To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time.

Memory Management. To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time. Memory Management To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time. Basic CPUs and Physical Memory CPU cache Physical memory

More information

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

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization 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

More information

Memory Management Virtual Memory

Memory Management Virtual Memory Memory Management Virtual Memory Part of A3 course (by Theo Schouten) Biniam Gebremichael http://www.cs.ru.nl/~biniam/ Office: A6004 April 4 2005 Content Virtual memory Definition Advantage and challenges

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

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

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 Virtual Memory

Chapter 8 Virtual Memory Operating Systems: Internals and Design Principles Chapter 8 Virtual Memory Seventh Edition William Stallings Operating Systems: Internals and Design Principles You re gonna need a bigger boat. Steven

More information

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

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

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

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

Virtual Memory. Chapter 8

Virtual Memory. Chapter 8 Virtual Memory 1 Chapter 8 Characteristics of Paging and Segmentation Memory references are dynamically translated into physical addresses at run time E.g., process may be swapped in and out of main memory

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

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

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

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

Operating Systems: Internals and Design Principles. Chapter 7 Memory Management Seventh Edition William Stallings

Operating Systems: Internals and Design Principles. Chapter 7 Memory Management Seventh Edition William Stallings Operating Systems: Internals and Design Principles Chapter 7 Memory Management Seventh Edition William Stallings Memory Management Requirements Memory management is intended to satisfy the following requirements:

More information

ECE519 Advanced Operating Systems

ECE519 Advanced Operating Systems IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (8 th Week) (Advanced) Operating Systems 8. Virtual Memory 8. Outline Hardware and Control Structures Operating

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

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

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

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

16 Sharing Main Memory Segmentation and Paging

16 Sharing Main Memory Segmentation and Paging Operating Systems 64 16 Sharing Main Memory Segmentation and Paging Readings for this topic: Anderson/Dahlin Chapter 8 9; Siberschatz/Galvin Chapter 8 9 Simple uniprogramming with a single segment per

More information

Role of OS in virtual memory management

Role of OS in virtual memory management Role of OS in virtual memory management Role of OS memory management Design of memory-management portion of OS depends on 3 fundamental areas of choice Whether to use virtual memory or not Whether to use

More information

15 Sharing Main Memory Segmentation and Paging

15 Sharing Main Memory Segmentation and Paging Operating Systems 58 15 Sharing Main Memory Segmentation and Paging Readings for this topic: Anderson/Dahlin Chapter 8 9; Siberschatz/Galvin Chapter 8 9 Simple uniprogramming with a single segment per

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

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

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

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

How to create a process? What does process look like?

How to create a process? What does process look like? How to create a process? On Unix systems, executable read by loader Compile time runtime Ken Birman ld loader Cache Compiler: generates one object file per source file Linker: combines all object files

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

Operating Systems. Operating Systems Sina Meraji U of T

Operating Systems. Operating Systems Sina Meraji U of T Operating Systems Operating Systems Sina Meraji U of T Recap Last time we looked at memory management techniques Fixed partitioning Dynamic partitioning Paging Example Address Translation Suppose addresses

More information

Process size is independent of the main memory present in the system.

Process size is independent of the main memory present in the system. Hardware control structure Two characteristics are key to paging and segmentation: 1. All memory references are logical addresses within a process which are dynamically converted into physical at run time.

More information

Operating Systems (2INC0) 2017/18

Operating Systems (2INC0) 2017/18 Operating Systems (2INC0) 2017/18 Memory Management (09) Dr. Courtesy of Dr. I. Radovanovic, Dr. R. Mak (figures from Bic & Shaw) System Architecture and Networking Group Agenda Reminder: OS & resources

More information

Memory Management Prof. James L. Frankel Harvard University

Memory Management Prof. James L. Frankel Harvard University Memory Management Prof. James L. Frankel Harvard University Version of 5:42 PM 25-Feb-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved. Memory Management Ideal memory Large Fast Non-volatile

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 Virtual Memory

Chapter 8 Virtual Memory Operating Systems: Internals and Design Principles Chapter 8 Virtual Memory Seventh Edition William Stallings Modified by Rana Forsati for CSE 410 Outline Principle of locality Paging - Effect of page

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

Operating System Support

Operating System Support Operating System Support Objectives and Functions Convenience Making the computer easier to use Efficiency Allowing better use of computer resources Layers and Views of a Computer System Operating System

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

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo PAGE REPLACEMENT Operating Systems 2015 Spring by Euiseong Seo Today s Topics What if the physical memory becomes full? Page replacement algorithms How to manage memory among competing processes? Advanced

More information

Virtual to physical address translation

Virtual to physical address translation Virtual to physical address translation Virtual memory with paging Page table per process Page table entry includes present bit frame number modify bit flags for protection and sharing. Page tables can

More information

Chapter 4: Memory Management. Part 1: Mechanisms for Managing Memory

Chapter 4: Memory Management. Part 1: Mechanisms for Managing Memory Chapter 4: Memory Management Part 1: Mechanisms for Managing Memory Memory management Basic memory management Swapping Virtual memory Page replacement algorithms Modeling page replacement algorithms Design

More information

CPE300: Digital System Architecture and Design

CPE300: Digital System Architecture and Design CPE300: Digital System Architecture and Design Fall 2011 MW 17:30-18:45 CBC C316 Virtual Memory 11282011 http://www.egr.unlv.edu/~b1morris/cpe300/ 2 Outline Review Cache Virtual Memory Projects 3 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

DAT (cont d) Assume a page size of 256 bytes. physical addresses. Note: Virtual address (page #) is not stored, but is used as an index into the table

DAT (cont d) Assume a page size of 256 bytes. physical addresses. Note: Virtual address (page #) is not stored, but is used as an index into the table Assume a page size of 256 bytes 5 Page table size (determined by size of program) 1 1 0 1 0 0200 00 420B 00 xxxxxx 1183 00 xxxxxx physical addresses Residency Bit (0 page frame is empty) Note: Virtual

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

ECE468 Computer Organization and Architecture. Virtual Memory

ECE468 Computer Organization and Architecture. Virtual Memory ECE468 Computer Organization and Architecture Virtual Memory ECE468 vm.1 Review: The Principle of Locality Probability of reference 0 Address Space 2 The Principle of Locality: Program access a relatively

More information

Objectives and Functions Convenience. William Stallings Computer Organization and Architecture 7 th Edition. Efficiency

Objectives and Functions Convenience. William Stallings Computer Organization and Architecture 7 th Edition. Efficiency William Stallings Computer Organization and Architecture 7 th Edition Chapter 8 Operating System Support Objectives and Functions Convenience Making the computer easier to use Efficiency Allowing better

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 2018 L20 Virtual Memory Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 Questions from last time Page

More information

ECE4680 Computer Organization and Architecture. Virtual Memory

ECE4680 Computer Organization and Architecture. Virtual Memory ECE468 Computer Organization and Architecture Virtual Memory If I can see it and I can touch it, it s real. If I can t see it but I can touch it, it s invisible. If I can see it but I can t touch it, it

More information

Chapter 3 Memory Management: Virtual Memory

Chapter 3 Memory Management: Virtual Memory Memory Management Where we re going Chapter 3 Memory Management: Virtual Memory Understanding Operating Systems, Fourth Edition Disadvantages of early schemes: Required storing entire program in memory

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

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

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

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

Operating Systems Unit 6. Memory Management

Operating Systems Unit 6. Memory Management Unit 6 Memory Management Structure 6.1 Introduction Objectives 6.2 Logical versus Physical Address Space 6.3 Swapping 6.4 Contiguous Allocation Single partition Allocation Multiple Partition Allocation

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

Course Outline. Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems

Course Outline. Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems Course Outline Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems 1 Today: Memory Management Terminology Uniprogramming Multiprogramming Contiguous

More information

stack Two-dimensional logical addresses Fixed Allocation Binary Page Table

stack Two-dimensional logical addresses Fixed Allocation Binary Page Table Question # 1 of 10 ( Start time: 07:24:13 AM ) Total Marks: 1 LRU page replacement algorithm can be implemented by counter stack linked list all of the given options Question # 2 of 10 ( Start time: 07:25:28

More information

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced? Chapter 10: Virtual Memory Questions? CSCI [4 6] 730 Operating Systems Virtual Memory!! What is virtual memory and when is it useful?!! What is demand paging?!! When should pages in memory be replaced?!!

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

Virtual Memory III. Jo, Heeseung

Virtual Memory III. Jo, Heeseung Virtual Memory III Jo, Heeseung Today's Topics What if the physical memory becomes full? Page replacement algorithms How to manage memory among competing processes? Advanced virtual memory techniques Shared

More information

Unit II: Memory Management

Unit II: Memory Management Unit II: Memory Management 1. What is no memory abstraction? The simplest memory abstraction is no abstraction at all. Early mainframe computers (before 1960), early minicomputers (before 1970), and early

More information

Chapter 8. Operating System Support. Yonsei University

Chapter 8. Operating System Support. Yonsei University Chapter 8 Operating System Support Contents Operating System Overview Scheduling Memory Management Pentium II and PowerPC Memory Management 8-2 OS Objectives & Functions OS is a program that Manages the

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

21 Lecture: More VM Announcements From last time: Virtual Memory (Fotheringham, 1961)

21 Lecture: More VM Announcements From last time: Virtual Memory (Fotheringham, 1961) 21 Lecture: More VM Outline: Announcements From last time: Virtual Memory (Fotheringham, 1961) What it s all about Translation Logistics(HERE) Where to keep the page table? Possible approaches to dealing

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

1. Creates the illusion of an address space much larger than the physical memory

1. Creates the illusion of an address space much larger than the physical memory Virtual memory Main Memory Disk I P D L1 L2 M Goals Physical address space Virtual address space 1. Creates the illusion of an address space much larger than the physical memory 2. Make provisions for

More information

Week 2: Tiina Niklander

Week 2: Tiina Niklander Virtual memory Operations and policies Chapters 3.4. 3.6 Week 2: 17.9.2009 Tiina Niklander 1 Policies and methods Fetch policy (Noutopolitiikka) When to load page to memory? Placement policy (Sijoituspolitiikka

More information

Operating Systems CSE 410, Spring Virtual Memory. Stephen Wagner Michigan State University

Operating Systems CSE 410, Spring Virtual Memory. Stephen Wagner Michigan State University Operating Systems CSE 410, Spring 2004 Virtual Memory Stephen Wagner Michigan State University Virtual Memory Provide User an address space that is larger than main memory Secondary storage is used to

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

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

Virtual Memory Virtual memory first used to relive programmers from the burden of managing overlays.

Virtual Memory Virtual memory first used to relive programmers from the burden of managing overlays. CSE420 Virtual Memory Prof. Mokhtar Aboelaze York University Based on Slides by Prof. L. Bhuyan (UCR) Prof. M. Shaaban (RIT) Virtual Memory Virtual memory first used to relive programmers from the burden

More information

Operating Systems, Fall

Operating Systems, Fall Policies and methods Virtual memory Operations and policies Chapters 3.4. 3.6 Week 2: 17.9.2009 Tiina Niklander 1 Fetch policy (Noutopolitiikka) When to load page to memory? Placement policy (Sijoituspolitiikka

More information

Unit 2 Buffer Pool Management

Unit 2 Buffer Pool Management Unit 2 Buffer Pool Management Based on: Sections 9.4, 9.4.1, 9.4.2 of Ramakrishnan & Gehrke (text); Silberschatz, et. al. ( Operating System Concepts ); Other sources Original slides by Ed Knorr; Updates

More information

Operating Systems. User OS. Kernel & Device Drivers. Interface Programs. Memory Management

Operating Systems. User OS. Kernel & Device Drivers. Interface Programs. Memory Management Operating Systems User OS Kernel & Device Drivers Interface Programs Management Brian Mitchell (bmitchel@mcs.drexel.edu) - Operating Systems 1 Management is an important resource that needs to be managed

More information

Memory: Paging System

Memory: Paging System Memory: Paging System Instructor: Hengming Zou, Ph.D. In Pursuit of Absolute Simplicity 求于至简, 归于永恒 Content Paging Page table Multi-level translation Page replacement 2 Paging Allocate physical memory in

More information

Memory Hierarchy. Goal: Fast, unlimited storage at a reasonable cost per bit.

Memory Hierarchy. Goal: Fast, unlimited storage at a reasonable cost per bit. Memory Hierarchy Goal: Fast, unlimited storage at a reasonable cost per bit. Recall the von Neumann bottleneck - single, relatively slow path between the CPU and main memory. Fast: When you need something

More information

CPS104 Computer Organization and Programming Lecture 16: Virtual Memory. Robert Wagner

CPS104 Computer Organization and Programming Lecture 16: Virtual Memory. Robert Wagner CPS104 Computer Organization and Programming Lecture 16: Virtual Memory Robert Wagner cps 104 VM.1 RW Fall 2000 Outline of Today s Lecture Virtual Memory. Paged virtual memory. Virtual to Physical translation:

More information

Memory Management. Motivation

Memory Management. Motivation Memory Management Vera Goebel Department of Informatics University of Oslo Basic memory management: Mono- and multi-programming Fixed and variable memory partitioning Swapping Paging Segmentation Virtual

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

Address spaces and memory management

Address spaces and memory management Address spaces and memory management Review of processes Process = one or more threads in an address space Thread = stream of executing instructions Address space = memory space used by threads Address

More information

Page Replacement Chap 21, 22. Dongkun Shin, SKKU

Page Replacement Chap 21, 22. Dongkun Shin, SKKU Page Replacement Chap 21, 22 1 Virtual Memory Concept Virtual memory Concept A technique that allows the execution of processes that are not completely in memory Partition each user s program into multiple

More information

Lecture 12: Demand Paging

Lecture 12: Demand Paging Lecture 1: Demand Paging CSE 10: Principles of Operating Systems Alex C. Snoeren HW 3 Due 11/9 Complete Address Translation We started this topic with the high-level problem of translating virtual addresses

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

Perform page replacement. (Fig 8.8 [Stal05])

Perform page replacement. (Fig 8.8 [Stal05]) Virtual memory Operations and policies Chapters 3.4. 3.7 1 Policies and methods Fetch policy (Noutopolitiikka) When to load page to memory? Placement policy (Sijoituspolitiikka ) Where to place the new

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

CS 31: Intro to Systems Virtual Memory. Kevin Webb Swarthmore College November 15, 2018

CS 31: Intro to Systems Virtual Memory. Kevin Webb Swarthmore College November 15, 2018 CS 31: Intro to Systems Virtual Memory Kevin Webb Swarthmore College November 15, 2018 Reading Quiz Memory Abstraction goal: make every process think it has the same memory layout. MUCH simpler for compiler

More information

Virtual Memory. 1 Administrivia. Tom Kelliher, CS 240. May. 1, Announcements. Homework, toolboxes due Friday. Assignment.

Virtual Memory. 1 Administrivia. Tom Kelliher, CS 240. May. 1, Announcements. Homework, toolboxes due Friday. Assignment. Virtual Memory Tom Kelliher, CS 240 May. 1, 2002 1 Administrivia Announcements Homework, toolboxes due Friday. Assignment From Last Time Introduction to caches. Outline 1. Virtual memory. 2. System support:

More information

Memory management. Knut Omang Ifi/Oracle 10 Oct, 2012

Memory management. Knut Omang Ifi/Oracle 10 Oct, 2012 Memory management Knut Omang Ifi/Oracle 1 Oct, 212 (with slides from V. Goebel, C. Griwodz (Ifi/UiO), P. Halvorsen (Ifi/UiO), K. Li (Princeton), A. Tanenbaum (VU Amsterdam), and M. van Steen (VU Amsterdam))

More information

Operating Systems (1DT020 & 1TT802) Lecture 9 Memory Management : Demand paging & page replacement. Léon Mugwaneza

Operating Systems (1DT020 & 1TT802) Lecture 9 Memory Management : Demand paging & page replacement. Léon Mugwaneza Operating Systems (1DT020 & 1TT802) Lecture 9 Memory Management : Demand paging & page replacement May 05, 2008 Léon Mugwaneza http://www.it.uu.se/edu/course/homepage/os/vt08 Review: Multiprogramming (with

More information

4.1 Paging suffers from and Segmentation suffers from. Ans

4.1 Paging suffers from and Segmentation suffers from. Ans Worked out Examples 4.1 Paging suffers from and Segmentation suffers from. Ans: Internal Fragmentation, External Fragmentation 4.2 Which of the following is/are fastest memory allocation policy? a. First

More information

Chapter 3 - Memory Management

Chapter 3 - Memory Management Chapter 3 - Memory Management Luis Tarrataca luis.tarrataca@gmail.com CEFET-RJ L. Tarrataca Chapter 3 - Memory Management 1 / 222 1 A Memory Abstraction: Address Spaces The Notion of an Address Space Swapping

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 super big to hold a program

More information

UNIT III MEMORY MANAGEMENT

UNIT III MEMORY MANAGEMENT UNIT III MEMORY MANAGEMENT TOPICS TO BE COVERED 3.1 Memory management 3.2 Contiguous allocation i Partitioned memory allocation ii Fixed & variable partitioning iii Swapping iv Relocation v Protection

More information