Operating Systems and Computer Networks. Memory Management. Dr.-Ing. Pascal A. Klein
|
|
- Helena Johnston
- 6 years ago
- Views:
Transcription
1 Operating Systems and Computer Networks Memory Management Alexander Maxeiner, M.Sc. Faculty of Engineering
2 Agenda 1 Swapping 2 Segmentation Algorithms 3 Memory Allocation 4 Virtual Memory 5 Paging 6 Page Replacement Algorithms 2
3 Memory Management Goals of Memory Management Convenient abstraction for programming Allocation of scarce memory resources among competing processes maximize performance with minimal overhead Mechanisms Physical and virtual addressing Partitioning, Paging, Segmentation Page replacement algorithms 3
4 Memory Hierarchy (1) small size small capacity small size small capacity Power on Power on Immediate term processor registers very fast, very expensive processor cache very fast, very expensive medium size medium capacity Power on very short term Random access memory fast, affordable medium size large capacity Power off short term flash / USB memory slower, cheap Large size very large capacity Large size very large capacity Power off mid term Power off Long term hard drives slow, very cheap Tape backup very slow, affordable 4
5 Memory Hierarchy (2) small size small capacity small size small capacity medium size medium capacity Large size very large capacity processor registers very fast, very expensive Power on Power on Immediate term Power on very short term Power off mid term processor cache very fast, very expensive Random access memory fast, affordable hard drives slow, very cheap 5
6 Sharing of Memory Program 1 Free Space Program 3 Program 2 Free Space OS Allocation Protection from each other, Protecting OS Translating logical addresses to physical Swapping (if physical memory is too small for all processes) Virtual memory (memory abstraction) 6
7 Memory Strategies Program 1 Free Space Program 3 Program 2 Free Space OS Fetch strategy When AND how much to load at a time (e.g.: prefetching) Placement (or allocation) strategy Determination WHERE data is to be placed Replacement strategy Determination WHICH area can be removed Variations Fixed partitions Variable partitions Segmentation paging Early computers, AND embedded, small, etc... Modern PCs 7
8 No Memory Abstraction (1) MOV REG1, 1000 set of physical addresses from 0 to... one program only How to execute more than one program? OS Program Program OS 8
9 Assumption: Increased Size - no Memory Abstraction Divide all physical memory into a fixed set of contiguous partitions Place only one process at a time in any partition Partition boundaries limit the available memory for each process Proces either entirely in main memory or not No sharing between processes Memory wasting: partition internal fragmentation Free partitions too small Without virtual addressing protection problems! Without Swapping/virtual memory size problems! 12K 2K 6K OS: 2K 9
10 Swapping 10
11 Memory Abstraction Swapping Free Space Issue: memory (RAM) is too small swap data on slower but bigger memory Swapper decides which processes should be in main memory OS 11
12 Swapping Example Assumption: 180K of Memory, OS: 20K 180K OS: 20K 12
13 Swapping Example Assumption: 180K of Memory, OS: 20K Process A (30K) is created or swapped in 150K Process A: 30K OS: 20K 13
14 Swapping Example 100K Assumption: 180K of Memory, OS: 20K Process A (30K) is created or swapped in Process B (50K) is created or swapped in Process B: 50K Process A: 30K OS: 20K 14
15 Swapping Example 80K Process C: 20K Assumption: 180K of Memory, OS: 20K Process A (30K) is created or swapped in Process B (50K) is created or swapped in Process C (20K) is created or swapped in Process B: 50K Process A: 30K OS: 20K 15
16 Swapping Example 60K Process D: 20K Process C: 20K Assumption: 180K of Memory, OS: 20K Process A (30K) is created or swapped in Process B (50K) is created or swapped in Process C (20K) is created or swapped in Process D (20K) is created or swapped in Process B: 50K Process A: 30K OS: 20K 16
17 Swapping Example 60K Process D: 20K Process C: 20K Process B: 50K Assumption: 180K of Memory, OS: 20K Process A (30K) is created or swapped in Process B (50K) is created or swapped in Process C (20K) is created or swapped in Process D (20K) is created or swapped in Process A is swapped out to disk 30K OS: 20K 17
18 Swapping Example 60K Process D: 20K 20K Process B: 50K 30K Assumption: 180K of Memory, OS: 20K Process A (30K) is created or swapped in Process B (50K) is created or swapped in Process C (20K) is created or swapped in Process D (20K) is created or swapped in Process A is swapped out to disk Process C is swapped out to disk What is the problem? OS: 20K 18
19 Swapping Issue Memory Fragmentation Memory Compaction Problem: CPU time Fixed size of partitions Problem: growing memory Bigger partitions with room for grow (here: heap) Variable size of partitions Management with Bit-Maps or Linked Lists Free Space Process C Free Space Process D OS Trade-off: Space requirements vs. time for allocation 19
20 Managing free space with Bit-Maps 60K Process D: 20K 20K Process B: 50K 30K OS: 20K Memory division into allocation units Corresponding bit for each allocation unit (0,1) telling whether it is free or not Example: Allocation units of 10KiB For current 20 bits: Trade-off: Bit-Map size depends on allocation unit searching for k consecutive 0-bits in map costly, fixed size 20
21 Managing free space with Linked Lists 60K Process D: 20K 20K Process B: 50K 30K Linked list of allocated and free memory segments Each record has Process ID/ Free (H: hole) Start address length pointer to next record H 2 3 B 5 5 H 10 2 OS: 20K D 12 2 H
22 Managing free space with Linked Lists 60K Process D: 20K 20K Update Process: When a process is swapped out, neighbouring blocks need to be examined doubly linked lists (containing a pointer to the next AND previous node Process B: 50K 30K H 2 3 P 5 5 H 10 2 OS: 20K P 12 2 H
23 Algorithms to allocate memory 60K Process D: 20K 20K Process B: 50K 30K Assuming a new process E requests 15K Which hole should it use? Available algorithms First fit Next fit Best fit Worst fit OS: 20K 23
24 Memory Allocation: First Fit 60K Process D: 20K 20K Process B: 50K simplest algorithm scanning along the list (from beginning) until it finds sufficient hole Breaking hole in two pieces: One for process One for unused memory (new hole) 30K OS: 20K 24
25 Memory Allocation: First Fit 60K Process D: 20K 20K Process B: 50K Free: 15K Process E:15K OS: 20K simplest algorithm scanning along the list (from beginning) until it finds sufficient hole Breaking hole in two pieces: stop start One for process One for unused memory (new hole) Fitting into 30K hole Very fast searches as little as possible 25
26 Memory Allocation: Next Fit 60K Process D: 20K 20K Process B: 50K 30K Variation of First Fit Keeps track of where it found a hole Next time: start at position where it left off last time Assumption that prospective fitting holes come after already found holes However, slight worse performance than first fit OS: 20K 26
27 Memory Allocation: Next Fit 60K Process D: 20K 20K Process B: 50K Free: 15K Process E:15K OS: 20K Variation of First Fit Keeps track of where it found a hole Next time: start at position where it left off last time Assumption that prospective fitting holes come after already found holes stop start However, slight worse performance than first fit Fitting into 30K hole 27
28 Memory Allocation: Next Fit 60K Process D: 20K Free: 5K Process F:15K Process B: 50K Free: 15K Process E:15K OS: 20K Variation of First Fit Keeps track of where it found a hole Next time: start at position where it left off last time stop Assumption that prospective fitting holes come after already found holes start However, slight worse performance than first fit Fitting into 30K hole Then, fitting into 20K hole 28
29 Memory Allocation: Best Fit 60K Process D: 20K 20K Searches entire list (from beginning to end) Takes smallest hole Assumption of best memory spacial performance Process B: 50K 30K OS: 20K 29
30 Memory Allocation: Best Fit 60K Process D: 20K Free: 5K Process E:15K Process B: 50K 30K OS: 20K stop Searches entire list (from beginning to end) Takes smallest hole Assumption of best memory spacial performance Fitting into 20K hole Takes much CPU time (for searching) Resulting in more memory wasting because of numerous tiny useless holes. start 30
31 Memory Allocation: Worst Fit 60K Process D: 20K 20K Variation of best fit Always takes the largest hole Assumption to get around splitting into tiny holes, to be big enough for other processes Process B: 50K 30K OS: 20K 31
32 Memory Allocation: Worst Fit 45K Process E:15K Process D: 20K 20K Process B: 50K 30K OS: 20K stop Variation of best fit Always takes the largest hole Assumption to get around splitting into tiny holes, to be big enough for other processes start Fitting into 60K hole Takes much CPU time (for searching) Still memory wasting 32
33 Memory Allocation: Enhancing performance Maintaining separate lists for processes AND holes Algorithms devote energy to inspect holes NOT processes BUT higher effort for deallocating (changing both lists) Sorting of lists regarding size enhancing speed of Best Fit/Worst Fit In practice: FF is usually better NF is pointless when sorted lists are used 33
34 Buddy System Memory encapsulated in units of powers of 2 Process requests rounded up to fit into units Possible hole sizes:..., 4K, 8K, 16K, 32K, 64K, 128K,... 64K 32K 16K 8K 4K 4K 34
35 Buddy System Example: Suppose a memory of 128K One hole of 128K Process A requests 6K rounded to 8K (2K wasted) 128K 35
36 Buddy System 64K 128K 32K Example: Suppose a memory of 128K One hole of 128K Process A requests 6K rounded to 8K (2K wasted) Process B requests 5K rounded to 8K (3K wasted) 16K 8K A: 8K 36
37 Buddy System 64K 32K Example: Suppose a memory of 128K One hole of 128K Process A requests 6K rounded to 8K (2K wasted) Process B requests 5K rounded to 8K (3K wasted) Process C requests 24K rounded to 32K (8K wasted) 16K B: 8K A: 8K 37
38 Buddy System 64K C: 32K 16K B: 8K A: 8K Example: Suppose a memory of 128K One hole of 128K Process A requests 6K rounded to 8K (2K wasted) Process B requests 5K rounded to 8K (3K wasted) Process C requests 24K rounded to 32K (8K wasted) Process D requests 3K rounded to 4K (1K wasted) 38
39 Buddy System 64K C: 32K 8K 4K D: 4K B: 8K A: 8K Example: Suppose a memory of 128K One hole of 128K Process A requests 6K rounded to 8K (2K wasted) Process B requests 5K rounded to 8K (3K wasted) Process C requests 24K rounded to 32K (8K wasted) Process D requests 3K rounded to 4K (1K wasted) Process A exits 39
40 Buddy System 64K C: 32K 8K 4K D: 4K B: 8K 8K Example: Suppose a memory of 128K One hole of 128K Process A requests 6K rounded to 8K (2K wasted) Process B requests 5K rounded to 8K (3K wasted) Process C requests 24K rounded to 32K (8K wasted) Process D requests 3K rounded to 4K (1K wasted) Process A exits Process B exits 40
41 Buddy System 64K C: 32K 8K 4K D: 4K 16K Example: Suppose a memory of 128K One hole of 128K Process A requests 6K rounded to 8K (2K wasted) Process B requests 5K rounded to 8K (3K wasted) Process C requests 24K rounded to 32K (8K wasted) Process D requests 3K rounded to 4K (1K wasted) Process A exits Process B exits 41
42 Virtual Memory 42
43 Virtual Addressing Program 1 Free Space Program 3 Program 2 Free Space OS address space address space address space Issue: By using physical addresses all executions are absolutely adressed NOT relatively! Better memory management with logical addresses Independancy of actual physical location of data in physical memory OS determines logical location of data CPU instructions using virtual addresses (don t care about location) Translated by hardware into physical address 43
44 Virtual Memory Software size much bigger than available RAM Each program s address space broken up into chunks Pages Page: contiguous range of addresses mapped onto physical memory Not all pages have to be in physical memory If OS notices, a program part is not in physical memory, it needs to be loaded and re-executed In Multiprogramming: While program is waiting for pieces of itself to be read in, CPU can execute another process 44
45 Paging Page: Fixed size unit in virtual memory Page frame: corresponding units in physical memory Same size (here: 4KB) Transparent to the program Protection a program cannot leave Virtual Address Space Example: 64KB virtual address space, 32KB physical space, 4KB page size How many pages/page frames? Answer: 16 virtual pages, 8 page frames 45
46 Relationship between virtual and physical memory virtual address space Addresses No KB-64KB... 4KB-8KB 0KB-4KB KB-32KB... 4KB-8KB 0KB-4KB page frame 46
47 Relationship between virtual and physical memory virtual address space Addresses No KB-64KB... 4KB-8KB 0KB-4KB KB-32KB... 4KB-8KB 0KB-4KB page frame MOV REG, 0 MMU checks VM page 0 corresponds to page frame 1 Address is changed to
48 Relationship between virtual and physical memory virtual address space Addresses No KB-64KB... 4KB-8KB 0KB-4KB KB-32KB... 4KB-8KB 0KB-4KB page frame MOV REG, 8192 MMU checks VM page 8192 corresponds to page frame 3 Address is changed to
49 Relationship between virtual and physical memory virtual address space Addresses No KB-64KB... 4KB-8KB 0KB-4KB KB-32KB... 4KB-8KB 0KB-4KB MOV REG, MMU checks VM page corresponds to page frame 4 with an offset of 20 Byte ( ) Address is changed to ( ) page frame 49
50 Memory Management Unit (MMU) p: page number d: offset r: page frame 50
51 Paging translating addresses Virtual address has two parts: virtual page number and offset Virtual page number is an index into a page table Page table determines page frame number Present/Absent bit if page is in physical memory What happens, if program references an unmapped address? (page fault) 51
52 Relationship between virtual and physical memory virtual address space Addresses No KB-64KB page fault!... 4KB-8KB 0KB-4KB MMU checks VM page fault! 28KB-32KB... 4KB-8KB 0KB-4KB MOV REG, page frame 52
53 Relationship between virtual and physical memory virtual address space Addresses No page fault! 60KB-64KB e.g.... 4KB-8KB 0KB-4KB MOV REG, MMU checks VM page fault! Choose a rarely used page frame (in phys. mem) Save content on hard drive KB-32KB... 4KB-8KB 0KB-4KB page frame 53
54 Relationship between virtual and physical memory virtual address space Addresses No page fault! 60KB-64KB e.g.... 4KB-8KB 0KB-4KB MOV REG, MMU checks VM page fault Choose a rarely used page frame (in phys. mem) Save content on hard drive Load requested page into phys. Mem KB-32KB... 4KB-8KB 0KB-4KB page frame 54
55 Relationship between virtual and physical memory virtual address space Addresses No page fault! 60KB-64KB e.g.... 4KB-8KB 0KB-4KB MOV REG, MMU checks VM page fault Choose a rarely used page frame (in phys. mem) Save content on hard drive Load requested page into phys. Mem KB-32KB... 4KB-8KB 0KB-4KB Restart trapped instruction page frame 55
56 Internal MMU operation Bit page number 4 Bit 16 pages present bit Bit page frame 12 Bit Offset Bit 4096 byte
57 Structure of a page table entry Strongly machine dependent M modified bit P present/absent bit M R P Prot Page frame number R reference bit Protection bits M/R bit protocol access to the page M-bit is set when a program writes to a page to know if it needs to be saved before physical space can be reused 57
58 Structure of a page table entry Strongly machine dependent M modified bit P present/absent bit M R P Prot Page frame number R reference bit Protection bits M/R bit protocol access to the page R-bit is set when read/write access occurs for decision if space should be used for overwriting 58
59 Structure of a page table entry Strongly machine dependent M modified bit P present/absent bit M R P Prot Page frame number R reference bit Protection bits P bit shows if page exists or not 59
60 Structure of a page table entry Strongly machine dependent M modified bit P present/absent bit M R P Prot Page frame number R reference bit Prot bits are setting rights which operations are allowed on a page E.g.: read, write, execute Protection bits 60
61 Paging advantages Easy to allocate memory Memory comes from a free list of fixed size chunks Allocating a page is just removing it from the list External fragmentation not a problem Easy to swap out chunks of a program All chunks are the same size Use present bit to detect references to swapped pages Pages are a convenient multiple of the disk block size 61
62 Paging disadvantages Memory reference overhead 2 references per address lookup (page table, then memory) Solution use a hardware cache of lookups Memory requirements to hold page tables can be significant 32 bit address space á 4KB pages = bytes/pte = 4MB per page table 25 processes = 100MB just for page tables! Solution multilevel page tables 62
63 Translation Lookaside Buffer (TLB) Observation, programs have most access on just a few pages Hardware Implementation TLB Part of MMU Small list of most important pages of a process (not more than 64) e.g. variables used in a loop Virtual page number, M-bit, Protect-bit, page frame, Validity Access: check TLB, if needed page can be found If NOT: fetch entry from page table, write entry to TLB (overwrite older entries) 63
64 Multilevel Page Table To be used for big virtual address spaces Dividing a page table into mulitple tables P= P=0 P=0 P=1... Two 4MB tables vs. of 1024*1024 entries 64
65 Page Replacement Algorithms Page fault! Load page into physical memory! Which page schould be replaced? Answer: pages which are rarely used! Possible Algorithms: Not Recently Used (NRU) Least Recently Used (LRU) First In First Out (FIFO) Second Chance (SC) 65
66 Not Recently Used Algorithm (NRU) Using status bits referenced (R) AND modified (M) Page Index M R P Prot Page frame Offset R-bit cleared periodically by OS M-bit cleared when hard disk updated Clearing random Entry of smallest availabe class: Best entry class 0. here: entry 1 or 3 is cleared! Class 0: R=0, M=0 Class 1: R=0, M=1 Class 2: R=1, M=0 Class 3: R=1, M=1 66
67 First In First Out Algorithm (FIFO) Oldest page entry (that loaded first) Page Index M R P Prot Page frame Offset Sorted list ordered by loading time Clear oldest entry no matter if referenced or modified Loaded here: entry 5 67
68 Second Chance Algorithm (SC) Enhancement of FIFO (by using R-Bit) Page Index M R P Prot Page frame Offset Linked list ordered by loading time Clear oldest entry if not referenced Loaded If entry is referenced clear R-bit and continue searching here: entry 5 and 0 will be unreferenced AND loading time reset, then, entry 2 will be cleared and used 68
69 Least Recently Used Algorithm (LRU) Clears page that has been unused for the longest time Page Index M R P Prot Page frame Offset Linked list ordered by access time based on asusmption, that pages used in the last few instructions will be used in the next few future instructions Problem: Entries have to be updated every access linked-list must be reordered ;-( here: entry 2 is cleared. (updated on hard drive first) Loaded Access
70 Questions? 70
71 Resources Tanenbaum, Andrew S., Modern Operating Systems, 3rd edition, Pearson Education Inc, Amsterdam, Netherlands, Tanenbaum, Andrew S., Moderne Bertriebssysteme, 3rd edition, Pearson Education Inc, Amsterdam, Netherlands, Lee, Insup, CsE 380 Computer Operating Systems, Lecture Notes, University of Pennsylvania, Snoeren, Alex C., Lecture 10: Memory Management, Lecture Notes, UC San Diego,
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 informationChapter 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 information12: 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 informationMemory Management Topics. CS 537 Lecture 11 Memory. Virtualizing Resources
Memory Management Topics CS 537 Lecture Memory Michael Swift Goals of memory management convenient abstraction for programming isolation between processes allocate scarce memory resources between competing
More informationMemory 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 informationMemory 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 informationMemory 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 informationMemory 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 informationCS399 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 informationOperating 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 informationVirtual Memory 1. To do. q Segmentation q Paging q A hybrid system
Virtual Memory 1 To do q Segmentation q Paging q A hybrid system Address spaces and multiple processes IBM OS/360 Split memory in n parts (possible!= sizes) A process per partition Program Code Heap Operating
More informationCS450/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 informationProcesses and Tasks What comprises the state of a running program (a process or task)?
Processes and Tasks What comprises the state of a running program (a process or task)? Microprocessor Address bus Control DRAM OS code and data special caches code/data cache EAXEBP EIP DS EBXESP EFlags
More informationVirtual Memory. Today. Segmentation Paging A good, if common example
Virtual Memory Today Segmentation Paging A good, if common example Virtual memory system Goals Transparency Programs should not know that memory is virtualized; the OS +HW multiplex memory among processes
More informationChapter 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 informationIn multiprogramming systems, processes share a common store. Processes need space for:
Memory Management In multiprogramming systems, processes share a common store. Processes need space for: code (instructions) static data (compiler initialized variables, strings, etc.) global data (global
More informationMemory Management. Goals of Memory Management. Mechanism. Policies
Memory Management Design, Spring 2011 Department of Computer Science Rutgers Sakai: 01:198:416 Sp11 (https://sakai.rutgers.edu) Memory Management Goals of Memory Management Convenient abstraction for programming
More informationCISC 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 informationAddresses 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 informationChapter 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 informationCSE 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 informationMemory Management. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory
Memory Management q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory Memory management Ideal memory for a programmer large, fast, nonvolatile and cheap not an option
More informationChapter 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 informationMemory management OS
Memory management 1 Memory (ideally) 2 Ideally Extremely fast (faster than the CPU in executing an instruction) Abundantly large Dirt cheap Memory (for real) 3 Typical access time 1 nsec Registers 2 nsec
More informationUNIT 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 informationMemory 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 informationMotivation. 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 informationMemory Allocation. Copyright : University of Illinois CS 241 Staff 1
Memory Allocation Copyright : University of Illinois CS 241 Staff 1 Recap: Virtual Addresses A virtual address is a memory address that a process uses to access its own memory Virtual address actual physical
More informationCS 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 informationCPS104 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 informationMemory Management. Memory Management. G53OPS: Operating Systems. Memory Management Monoprogramming 11/27/2008. Graham Kendall.
Memory Management Memory Management Introduction Graham Kendall Memory Management consists of many tasks, including Being aware of what parts of the memory are in use and which parts are not Allocating
More informationOperating 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 informationMemory Management. To do. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory
Memory Management To do q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory Memory management Ideal memory for a programmer large, fast, nonvolatile and cheap not
More informationMemory 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 informationMemory 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 informationMemory Management. Disclaimer: some slides are adopted from book authors slides with permission 1
Memory Management Disclaimer: some slides are adopted from book authors slides with permission 1 CPU management Roadmap Process, thread, synchronization, scheduling Memory management Virtual memory Disk
More informationOPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems 3rd edition Uses content with permission from Assoc. Prof. Florin Fortis, PhD
OPERATING SYSTEMS #8 After A.S.Tanenbaum, Modern Operating Systems 3rd edition Uses content with permission from Assoc. Prof. Florin Fortis, PhD MEMORY MANAGEMENT MEMORY MANAGEMENT The memory is one of
More informationOperating 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 informationOperating 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 informationCS370 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 informationMemory 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 informationRecall from Tuesday. Our solution to fragmentation is to split up a process s address space into smaller chunks. Physical Memory OS.
Paging 11/10/16 Recall from Tuesday Our solution to fragmentation is to split up a process s address space into smaller chunks. Physical Memory OS Process 3 Process 3 OS: Place Process 3 Process 1 Process
More informationVirtual Memory Management
Virtual Memory Management CS-3013 Operating Systems Hugh C. Lauer (Slides include materials from Slides include materials from Modern Operating Systems, 3 rd ed., by Andrew Tanenbaum and from Operating
More informationChapter 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 informationOperating 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 informationCPS 104 Computer Organization and Programming Lecture 20: Virtual Memory
CPS 104 Computer Organization and Programming Lecture 20: Virtual Nov. 10, 1999 Dietolf (Dee) Ramm http://www.cs.duke.edu/~dr/cps104.html CPS 104 Lecture 20.1 Outline of Today s Lecture O Virtual. 6 Paged
More informationHow 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 informationMemory and multiprogramming
Memory and multiprogramming COMP342 27 Week 5 Dr Len Hamey Reading TW: Tanenbaum and Woodhull, Operating Systems, Third Edition, chapter 4. References (computer architecture): HP: Hennessy and Patterson
More informationMEMORY MANAGEMENT. Jo, Heeseung
MEMORY MANAGEMENT Jo, Heeseung TODAY'S TOPICS Why is memory management difficult? Old memory management techniques: Fixed partitions Variable partitions Swapping Introduction to virtual memory 2 MEMORY
More informationOperating 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 informationOperating 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 informationCourse 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 informationMEMORY: SWAPPING. Shivaram Venkataraman CS 537, Spring 2019
MEMORY: SWAPPING Shivaram Venkataraman CS 537, Spring 2019 ADMINISTRIVIA - Project 2b is out. Due Feb 27 th, 11:59 - Project 1b grades are out Lessons from p2a? 1. Start early! 2. Sketch out a design?
More informationMemory 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 informationGoals 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 informationOperating Systems, Fall
Operating Systems: Memory management Fall 2008 Tiina Niklander Memory Management Programmer wants memory to be Indefinitely large Indefinitely fast Non volatile Memory hierarchy Memory manager handles
More informationOperating Systems, Fall
Operating Systems: Memory management Fall 2008 Basic Memory Management: One program Monoprogramming without Swapping or Paging Tiina Niklander No memory abstraction, no address space, just an operating
More informationOperating Systems. Paging... Memory Management 2 Overview. Lecture 6 Memory management 2. Paging (contd.)
Operating Systems Lecture 6 Memory management 2 Memory Management 2 Overview Paging (contd.) Structure of page table Shared memory Segmentation Segmentation with paging Virtual memory Just to remind you...
More informationChapter 3: Important Concepts (3/29/2015)
CISC 3595 Operating System Spring, 2015 Chapter 3: Important Concepts (3/29/2015) 1 Memory from programmer s perspective: you already know these: Code (functions) and data are loaded into memory when the
More informationVirtual 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 informationRequirements, Partitioning, paging, and segmentation
Requirements, Partitioning, paging, and segmentation Main Memory: The Big Picture kernel memory proc struct kernel stack/u area Stack kernel stack/u area Stack kernel stack/u area Stack Data Text (shared)
More informationMove 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 informationMemory 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 informationGoals of memory management
CSE 451: Operating Systems Winter 2004 Module 10 Memory Management Ed Lazowska lazowska@cs.washington.edu Allen Center 570 Goals of memory management Allocate scarce memory resources among competing processes,
More informationBasic 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 informationBasic 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 information15 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 informationMemory Management. Jo, Heeseung
Memory Management Jo, Heeseung Today's Topics Why is memory management difficult? Old memory management techniques: Fixed partitions Variable partitions Swapping Introduction to virtual memory 2 Memory
More informationTopics: 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 informationCS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University
Frequently asked questions from the previous class survey CS 370: OPERATING SYSTEMS [MEMORY MANAGEMENT] Shrideep Pallickara Computer Science Colorado State University MS-DOS.COM? How does performing fast
More information8: Memory Management
CSC400 - Operating Systems 8: Memory Management J. Sumey Physical Memory as important as the CPU, a computer's physical memory is another important resource that must be carefully & efficiently managed
More informationECE468 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 informationCS6401- 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 informationECE 598 Advanced Operating Systems Lecture 10
ECE 598 Advanced Operating Systems Lecture 10 Vince Weaver http://www.eece.maine.edu/~vweaver vincent.weaver@maine.edu 17 February 2015 Announcements Homework #1 and #2 grades, HW#3 Coming soon 1 Various
More informationECE4680 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 informationMemory Management. Disclaimer: some slides are adopted from book authors slides with permission 1
Memory Management Disclaimer: some slides are adopted from book authors slides with permission 1 Recap Paged MMU: Two main Issues Translation speed can be slow TLB Table size is big Multi-level page table
More informationa 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 informationChallenge managing memory
INF16: Introduction to Operating Systems and Data Communication Operating Systems: Memory Thursday 6 October 16 Challenge managing memory 1 Overview Hierarchies Multiprogramming and memory management Addressing
More informationVirtual 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 informationOperating 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 informationMEMORY 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 informationFrequently asked questions from the previous class survey
CS 370: OPERATING SYSTEMS [MEMORY MANAGEMENT] Shrideep Pallickara Computer Science Colorado State University L20.1 Frequently asked questions from the previous class survey Virtual addresses L20.2 SLIDES
More informationUnit 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 informationCS 550 Operating Systems Spring Memory Management: Page Replacement
CS 550 Operating Systems Spring 2018 Memory Management: Page Replacement 1 OS Involvement with Page Table Management Four times when OS deals with page-tables 1. Process creation create page table 2. Upon
More information!! 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 informationVirtual 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 informationLecture 7. Memory Management
Lecture 7 Memory Management 1 Lecture Contents 1. Memory Management Requirements 2. Memory Partitioning 3. Paging 4. Segmentation 2 Memory Memory is an array of words or bytes, each with its own address.
More informationMemory Management. CSE 2431: Introduction to Operating Systems Reading: , [OSC]
Memory Management CSE 2431: Introduction to Operating Systems Reading: 8.1 8.3, [OSC] 1 Outline Basic Memory Management Swapping Variable Partitions Memory Management Problems 2 Basic Memory Management
More informationWeek 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 information16 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 informationChapter 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 informationChapter 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 informationOperating Systems. IV. Memory Management
Operating Systems IV. Memory Management Ludovic Apvrille ludovic.apvrille@telecom-paristech.fr Eurecom, office 470 http://soc.eurecom.fr/os/ @OS Eurecom Outline Basics of Memory Management Hardware Architecture
More informationPerformance 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 informationCS 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 informationMemory: Overview. CS439: Principles of Computer Systems February 26, 2018
Memory: Overview CS439: Principles of Computer Systems February 26, 2018 Where We Are In the Course Just finished: Processes & Threads CPU Scheduling Synchronization Next: Memory Management Virtual Memory
More informationClassifying Information Stored in Memory! Memory Management in a Uniprogrammed System! Segments of a Process! Processing a User Program!
Memory Management in a Uniprogrammed System! A! gets a fixed segment of (usually highest )"! One process executes at a time in a single segment"! Process is always loaded at "! Compiler and linker generate
More informationRecall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory
Recall: Address Space Map 13: Memory Management Biggest Virtual Address Stack (Space for local variables etc. For each nested procedure call) Sometimes Reserved for OS Stack Pointer Last Modified: 6/21/2004
More informationMemory 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 informationObjectives 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