CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Size: px
Start display at page:

Download "CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017"

Transcription

1 CS 471 Operating Systems Yue Cheng George Mason University Fall 2017

2 Review: Segmentation 2

3 Virtual Memory Accesses o Approaches: Static Relocation Dynamic Relocation Base Base-and-Bounds Segmentation 3

4 Virtual Memory Accesses o Approaches: Static Relocation: requires rewrite for the same code Dynamic Relocation Base: add a base to virtual address to get physical address Base-and-Bounds: checks physical address is in range Segmentation: many base+bounds pairs 4

5 Virtual Memory Accesses o Approaches: Static Relocation: requires rewrite for the same code Dynamic Relocation Base: add a base to virtual address to get physical address Base-and-Bounds: checks physical address is in range Segmentation: many base+bounds pairs 5

6 Segmentation Example o Assume a 10-bit virtual address space With the high 2-bit indicating the segment o Assume 0 => code+data 1 => heap 2 => stack 6

7 Segmentation Example 0x000 Virtual 0x100 0x200 0x300 7

8 Segmentation Example 0x000 Virtual Code 0x100 Heap 0x200 0x300 Stack 8

9 Segmentation Example 0x000 Virtual Code 0x100 Heap 0x200 0x300 Stack base bounds code?? heap?? stack?? 9

10 Segmentation Example 0x000 Virtual Code 0x100 Heap 0x200 0x300 Stack base bounds code? 0x40 heap? 0xC0 stack? 0x80 10

11 Segmentation Example 0x000 Virtual Code Physical Heap 0x000 0x100 Code 0x400 Heap Stack 0x800 0x200 0x300 Stack base bounds code 0x400 0x40 heap 0 0xC0 stack 0x800 0x80 11

12 Segmentation Example 0x000 Virtual Code Physical Heap 0x000 0x100 Code 0x400 Heap Stack 0x800 0x200 0x300 Stack base bounds code 0x400 0x40 heap 0 0xC0 stack 0x800 0x80 12

13 Segmentation Example 0x000 Virtual Code Physical Heap 0x000 0x100 Code 0x400 Heap Stack 0x800 0x200 0x300 Stack base bounds code 0x400 0x40 heap 0 0xC0 stack 0x800 0x80 Most segments: phys = virt_offset + base 13

14 Segmentation Example 0x000 Virtual Code Physical Heap 0x000 0x100 Code 0x400 0x180 Heap Stack 0x800 0x200 0x300 Stack base bounds code 0x400 0x40 heap 0 0xC0 stack 0x800 0x80 Most segments: phys = virt_offset + base 14

15 Segmentation Example 0x000 Virtual Code Physical Heap 0x000 0x100 Code 0x400 0x180 Heap Stack 0x800 0x200 0x300 Stack base bounds code 0x400 0x40 heap 0 0xC0 stack 0x800 0x80 Most segments: phys = 0x80 + base 15

16 Segmentation Example 0x000 Virtual Code Physical Heap 0x000 0x100 Code 0x400 0x180 Heap Stack 0x800 0x200 0x300 Stack base bounds code 0x400 0x40 heap 0 0xC0 stack 0x800 0x80 Most segments: phys = 0x80 + base 16

17 Segmentation Example 0x000 Virtual Code Physical Heap 0x000 0x100 Code 0x400 0x180 Heap Stack 0x800 0x200 0x300 Stack base bounds code 0x400 0x40 heap 0 0xC0 stack 0x800 0x80 Most segments: phys = 0x

18 Segmentation Example 0x000 Virtual Code Physical Heap 0x000 0x100 Code 0x400 0x180 Heap Stack 0x800 0x200 0x300 Stack base bounds code 0x400 0x40 heap 0 0xC0 stack 0x800 0x80 Most segments: phys = 0x = 0x80 18

19 Segmentation Example 0x000 Virtual Code Physical Heap 0x000 0x100 Code 0x400 Heap Stack 0x800 0x200 0x300 Stack base bounds code 0x400 0x40 heap 0 0xC0 stack 0x800 0x80 What if heap needs to grow? 19

20 Segmentation Example 0x000 Virtual Code Physical Heap 0x000 0x100 Code Heap Stack 0x800 0x200 Copy 0x300 Stack base bounds code 0x400 0x40 heap 0 0xC0 stack 0x800 0x80 What if heap needs to grow? 20

21 Segmentation Example 0x000 Virtual Code Physical Heap 0x000 0x100 Heap Stack 0x800 0x200 Code 0x300 Stack base bounds code 0x400 0x40 heap 0 0xC0 stack 0x800 0x80 What if heap needs to grow? 21

22 Segmentation Example 0x000 Virtual Code Physical Heap 0x000 0x100 Heap Stack 0x800 0x200 Code 0xC00 0x300 Stack base bounds code 0xC00 0x40 heap 0 0xC0 stack 0x800 0x80 What if heap needs to grow? 22

23 Segmentation Example 0x000 Virtual Code Physical 0x000 Heap 0x100 Heap Stack 0x800 0x200 Code 0xC00 0x300 Stack base bounds code 0xC00 0x40 heap 0 0x100 stack 0x800 0x80 What if heap needs to grow? 23

24 Segmentation Example 0x000 Virtual Code Physical 0x000 Heap 0x100 Heap Stack 0x800 0x200 Code 0xC00 0x300 Stack base bounds code 0xC00 0x40 heap 0 0x100 stack 0x800 0x80 dilemma: must (a) waste space or (b) waste time 24

25 Issues: External Fragmentation o As processes are loaded and removed from the main memory, the free memory is broken into small pieces Hole: block of available memory; holes of various size are scattered throughout memory o A new allocation request may have to be denied When there is no contiguous free memory with requested size The total free memory space may be much larger than the requested size! Hole Hole Hole 25

26 Memory Compaction o Reduce external fragmentation by copy+compaction Shuffle memory contents to place all free memory together in one large block Compaction is possible only if relocation is dynamic, and is done at execution time Must be careful about pending I/O before initiating compaction Problems Too much perf overhead 26

27 Paging 27

28 Paging o Motivation: Segmentation is too coarse-grained Either waste space (external fragmentation) or copy memory often (compaction) o We need a finer-grained alternative! 28

29 Paging Scheme o A memory management scheme that allows the physical address space of a process to be noncontiguous o Divide physical memory into fixed-sized blocks called frames o Divide logical memory into blocks of same size called pages o Flexible mapping: Any page can go to any free frame o Scalability: To run a program of size n pages, need to find n free frames and load program Grow memory segments wherever we please! 29

30 A Simple Example page 0 page 1 page 2 An 8-frame physical memory (128B) page 3 Program s Virt Addr Space Each page is of 16B 30

31 A Simple Example page 0 page 1 page 2 An 8-frame physical memory (128B) page 3 Program s Virt Addr Space Each page is of 16B Virtual page # Physical frame # 31

32 Addressing Basics o For segmentation High bits => segment # Low bits => offset VPN offset o For paging High bits => page # Low bits => offset VA4 VA3 VA2 VA1 VA0 Q: How many offset bits do we need? A: log(page_size) 32

33 Address Examples Page size Low bits (offset) 16 Bytes 33

34 Address Examples Page size Low bits (offset) 16 Bytes 4 34

35 Address Examples Page size Low bits (offset) 16 Bytes 4 2 KB 35

36 Address Examples Page size Low bits (offset) 16 Bytes 4 2 KB 11 36

37 Address Examples Page size Low bits (offset) 16 Bytes 4 2 KB 11 4 MB 37

38 Address Examples Page size Low bits (offset) 16 Bytes 4 2 KB 11 4 MB 22 38

39 Address Examples Page size Low bits (offset) 16 Bytes 4 2 KB 11 4 MB Bytes 39

40 Address Examples Page size Low bits (offset) 16 Bytes 4 2 KB 11 4 MB Bytes 8 40

41 Address Examples Page size Low bits (offset) 16 Bytes 4 2 KB 11 4 MB Bytes 8 16 KB 41

42 Address Examples Page size Low bits (offset) 16 Bytes 4 2 KB 11 4 MB Bytes 8 16 KB 14 42

43 Address Examples Page size Low bits (offset) Virt Addr Bits High bits (vpn) 16 Bytes KB MB Bytes KB

44 Address Examples Page size Low bits (offset) Virt Addr Bits High bits (vpn) 16 Bytes KB MB Bytes KB

45 Address Examples Page size Low bits (offset) Virt Addr Bits High bits (vpn) 16 Bytes KB MB Bytes KB

46 Address Examples Page size Low bits (offset) Virt Addr Bits High bits (vpn) 16 Bytes KB MB Bytes KB

47 Address Examples Page size Low bits (offset) Virt Addr Bits High bits (vpn) 16 Bytes KB MB Bytes KB

48 Address Examples Page size Low bits (offset) Virt Addr Bits High bits (vpn) 16 Bytes KB MB Bytes KB

49 Address Examples Page size Low bits (offset) Virt Addr Bits High bits (vpn) Virt pages 16 Bytes KB MB Bytes KB

50 Address Examples Page size Low bits (offset) Virt Addr Bits High bits (vpn) Virt pages 16 Bytes KB MB K 256 Bytes KB

51 Address Examples Page size Low bits (offset) Virt Addr Bits High bits (vpn) Virt pages 16 Bytes KB MB K 256 Bytes KB Note: high bits for physical frames may be different! 51

52 Question: An x86_64 Linux OS with 4KB page size. How many pages can we have assuming the maximum memory limit? 52

53 Virtual => Physical Addr Mapping o We need a general mapping mechanism o What data structure is good? Big array VPN offset Addr mapper PFN offset 53

54 Virtual => Physical Addr Mapping o We need a general mapping mechanism o What data structure is good? Big array (aka linear page table) VPN offset Addr mapper PFN offset 54

55 Mapping Example P1 P2 Virtual mem Phys mem 55

56 Mapping Example P1 P2 Virtual mem Phys mem 56

57 Mapping Example P1 P2 Virtual mem Phys mem 57

58 Mapping Example P1 P2 Virtual mem Phys mem 58

59 Mapping Example P1 P2 Virtual mem Phys mem P1 P Page tables

60 Page Table o A per-process data structure used to keep track of virtual page to physical frame mapping o Major role: store address translation 60

61 Address Translation Scheme o Observe: The simple limit/relocation register pair mechanism is no longer sufficient o m-bit virtual address generated by CPU is divided into: Virtual Page number (p) used as an index into a page table which contains base address of each page in physical memory Page offset (d) combined with base address to define the physical memory address that is sent to the memory unit 61

62 Address Translation Architecture f logical address physical address f CPU p d f d f p f page table physical memory 62

63 Free Frames Before allocation After allocation 63

64 Free Frames Before allocation After allocation 64

65 More on Page Table o The page table data structure is kept in main memory o Each page table entry (PTE) holds <physical translation + other info> o Page-table base register (PTBR) points to the page table E.g., CR3 on x86 o Page-table length register (PTLR), if it exists, indicates the size of the page table 65

66 Page Table Entry (PTE) o The simplest form of a page table is a linear page table Array data structure OS indexes the array by virtual page number (VPN) To find the desired physical frame number (PFN) An 32-bit x86 page table entry (PTE) Important page status info 66

67 Paging Problems o Page tables are too slow (today) o Page tables are too big (next lecture) 67

68 Address Translation Steps o Hardware: for each memory reference 1. Extract VPN (virt page num) from VA (virt addr) 2. Calculate addr of PTE (page table entry) 3. Fetch PTE 4. Extract PFN (phys page frame num) 5. Build PA (phys addr) 6. Fetch PA to register o Q: Which steps are expensive?? 68

69 Address Translation Steps cheap cheap expensive cheap cheap expensive o Hardware: for each memory reference 1. Extract VPN (virt page num) from VA (virt addr) 2. Calculate addr of PTE (page table entry) 3. Fetch PTE 4. Extract PFN (phys page frame num) 5. Build PA (phys addr) 6. Fetch PA to register o Q: Which steps are expensive?? 69

70 Address Translation Steps cheap cheap expensive cheap cheap expensive o Hardware: for each memory reference 1. Extract VPN (virt page num) from VA (virt addr) 2. Calculate addr of PTE (page table entry) 3. Fetch PTE 4. Extract PFN (phys page frame num) 5. Build PA (phys addr) 6. Fetch PA to register o Q: Which expensive steps can we avoid?? 70

71 Array Iterator o A simple code snippet in array.c int sum = 0; for (i=0; i<n; i++) { sum += a[i]; } o Compile it using gcc o Dump the assembly code objdump (Linux) or otool (Mac) 71

72 Trace the Memory Accesses Virt load 0x3000 load 0x3004 load 0x3008 load 0x300C 72

73 Trace the Memory Accesses Virt load 0x3000 load 0x3004 load 0x3008 load 0x300C Phys load 0x100C load 0x7000 load 0x100C load 0x7004 load 0x100C load 0x7008 load 0x100C load 0x700C 73

74 Trace the Memory Accesses Virt load 0x3000 load 0x3004 load 0x3008 load 0x300C Phys load 0x100C load 0x7000 load 0x100C load 0x7004 load 0x100C load 0x7008 load 0x100C load 0x700C 1 st mem access: Fetch PTE 74

75 Trace the Memory Accesses Virt load 0x3000 load 0x3004 load 0x3008 load 0x300C Phys load 0x100C load 0x7000 load 0x100C load 0x7004 load 0x100C load 0x7008 load 0x100C load 0x700C Map VPN to PFN: 3 -> 7 75

76 Trace the Memory Accesses Virt load 0x3000 load 0x3004 load 0x3008 load 0x300C Phys load 0x100C load 0x7000 load 0x100C load 0x7004 load 0x100C load 0x7008 load 0x100C load 0x700C 2 nd mem access: access a[i] 76

77 Trace the Memory Accesses Virt load 0x3000 load 0x3004 load 0x3008 load 0x300C Phys load 0x100C load 0x7000 load 0x100C load 0x7004 load 0x100C load 0x7008 load 0x100C load 0x700C Note: 1. Each virt mem access -> two phys mem accesses 2. Repeated memory accesses! 77

Virtualizing Memory: Paging. Announcements

Virtualizing Memory: Paging. Announcements CS 537 Introduction to Operating Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department Andrea C. Arpaci-Dusseau Remzi H. Arpaci-Dusseau Virtualizing Memory: Paging Questions answered in

More information

CS 537 Lecture 6 Fast Translation - TLBs

CS 537 Lecture 6 Fast Translation - TLBs CS 537 Lecture 6 Fast Translation - TLBs Michael Swift 9/26/7 2004-2007 Ed Lazowska, Hank Levy, Andrea and Remzi Arpaci-Dussea, Michael Swift Faster with TLBS Questions answered in this lecture: Review

More information

Operating System Labs. Yuanbin Wu

Operating System Labs. Yuanbin Wu Operating System Labs Yuanbin Wu cs@ecnu Operating System Labs Review of Memory Management Early days Memory Management Memory Management Multiprogramming and Time Sharing Multiple processes live in memory

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

Simple idea 1: load-time linking. Our main questions. Some terminology. Simple idea 2: base + bound register. Protection mechanics.

Simple idea 1: load-time linking. Our main questions. Some terminology. Simple idea 2: base + bound register. Protection mechanics. Our main questions! How is protection enforced?! How are processes relocated?! How is ory partitioned? Simple idea 1: load-time linking! Link as usual, but keep the list of references! At load time, determine

More information

CS 550 Operating Systems Spring Memory Management: Paging

CS 550 Operating Systems Spring Memory Management: Paging CS 550 Operating Systems Spring 2018 Memory Management: Paging 1 Recap: Memory Management Ideally programmers want memory that is large fast non volatile Memory hierarchy small amount of fast, expensive

More information

Operating System Labs. Yuanbin Wu

Operating System Labs. Yuanbin Wu Operating System Labs Yuanbin Wu cs@ecnu Operating System Labs Review of Memory Management Early days Memory Management Memory Management Multiprogramming multiple processes could be ready to run at a

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

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

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

More information

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

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

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

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

CS 3733 Operating Systems:

CS 3733 Operating Systems: CS 3733 Operating Systems: Topics: Memory Management (SGG, Chapter 08) Instructor: Dr Dakai Zhu Department of Computer Science @ UTSA 1 Reminders Assignment 2: extended to Monday (March 5th) midnight:

More information

CS162 - Operating Systems and Systems Programming. Address Translation => Paging"

CS162 - Operating Systems and Systems Programming. Address Translation => Paging CS162 - Operating Systems and Systems Programming Address Translation => Paging" David E. Culler! http://cs162.eecs.berkeley.edu/! Lecture #15! Oct 3, 2014!! Reading: A&D 8.1-2, 8.3.1. 9.7 HW 3 out (due

More information

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

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

More information

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

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Paging Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics Virtual memory implementation Paging Segmentation 2 Paging (1) Paging Permits

More information

CS370 Operating Systems

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

More information

Recall from Tuesday. Our solution to fragmentation is to split up a process s address space into smaller chunks. Physical Memory OS.

Recall 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 information

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Paging Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Paging Allows the physical address space of a process to be noncontiguous Divide virtual

More information

Paging. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Paging. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University Paging Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE3044: Operating Systems, Fall 2016, Jinkyu Jeong (jinkyu@skku.edu) Paging Allows the physical

More information

Segmentation. Multiple Segments. Lecture Notes Week 6

Segmentation. Multiple Segments. Lecture Notes Week 6 At this point, we have the concept of virtual memory. The CPU emits virtual memory addresses instead of physical memory addresses. The MMU translates between virtual and physical addresses. Don't forget,

More information

CS307 Operating Systems Main Memory

CS307 Operating Systems Main Memory CS307 Main Memory Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2018 Background Program must be brought (from disk) into memory and placed within a process

More information

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 13: Address Translation

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 13: Address Translation CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004 Lecture 13: Address Translation 13.0 Main Points 13.1 Hardware Translation Overview CPU Virtual Address Translation

More information

Paging. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Paging. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University Paging Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics Virtual memory implementation Paging Segmentation 2 Paging (1) Paging Permits

More information

Memory Management (1) Memory Management

Memory Management (1) Memory Management EECS 3221 Operating System Fundamentals No.8 Memory Management (1) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Memory Management A program usually resides on a

More information

Memory Management (1) Memory Management. CPU vs. memory. No.8. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University

Memory Management (1) Memory Management. CPU vs. memory. No.8. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University EECS 3221 Operating System Fundamentals No.8 Memory Management (1) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Memory Management A program usually resides on a

More information

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

Introduction to Paging

Introduction to Paging Introduction to Paging COMS W4118 References: Operating Systems Concepts (9e), Linux Kernel Development, previous W4118s Copyright notice: care has been taken to use only those web images deemed by the

More information

COSC Operating Systems Design, Fall 2001, Byunggu Yu. Chapter 9 Memory Management (Lecture Note #8) 1. Background

COSC Operating Systems Design, Fall 2001, Byunggu Yu. Chapter 9 Memory Management (Lecture Note #8) 1. Background COSC4740 01 Operating Systems Design, Fall 2001, Byunggu Yu Chapter 9 Memory Management (Lecture Note #8) 1. Background The computer programs, together with the data they access, must be in main memory

More information

CS307: Operating Systems

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

More information

12: Memory Management

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

More information

Memory Management. Memory Management

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

More information

VIRTUAL MEMORY. Operating Systems 2015 Spring by Euiseong Seo

VIRTUAL MEMORY. Operating Systems 2015 Spring by Euiseong Seo VIRTUAL MEMORY Operating Systems 2015 Spring by Euiseong Seo Today s Topics Virtual memory implementation Paging Segmentation Paging Permits the physical address space of a process to be noncontiguous

More information

Lecture 8 Memory Management Strategies (chapter 8)

Lecture 8 Memory Management Strategies (chapter 8) Bilkent University Department of Computer Engineering CS342 Operating Systems Lecture 8 Memory Management Strategies (chapter 8) Dr. İbrahim Körpeoğlu http://www.cs.bilkent.edu.tr/~korpe 1 References The

More information

Operating Systems. Pablo Prieto Torralbo. 3. Memory Virtualizing DEPARTMENT OF COMPUTER ENGINEERING

Operating Systems. Pablo Prieto Torralbo. 3. Memory Virtualizing DEPARTMENT OF COMPUTER ENGINEERING Operating Systems 3. Memory Virtualizing Pablo Prieto Torralbo DEPARTMENT OF COMPUTER ENGINEERING AND ELECTRONICS This material is published under: Creative Commons BY-NC-SA 4. 3.1 Memory Virtualization

More information

Virtual Memory. Today. Segmentation Paging A good, if common example

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

Principles of Operating Systems

Principles of Operating Systems Principles of Operating Systems Lecture 18-20 - Main Memory Ardalan Amiri Sani (ardalan@uci.edu) [lecture slides contains some content adapted from previous slides by Prof. Nalini Venkatasubramanian, and

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

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

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

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

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

More information

The Memory Management Unit. Operating Systems. Autumn CS4023

The Memory Management Unit. Operating Systems. Autumn CS4023 Operating Systems Autumn 2017-2018 Outline The Memory Management Unit 1 The Memory Management Unit Logical vs. Physical Address Space The concept of a logical address space that is bound to a separate

More information

EECS 482 Introduction to Operating Systems

EECS 482 Introduction to Operating Systems EECS 482 Introduction to Operating Systems Fall 2018 Baris Kasikci Slides by: Harsha V. Madhyastha Base and bounds Load each process into contiguous region of physical memory Prevent process from accessing

More information

Memory Management Topics. CS 537 Lecture 11 Memory. Virtualizing Resources

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

Administrivia. Lab 1 due Friday 12pm. We give will give short extensions to groups that run into trouble. But us:

Administrivia. Lab 1 due Friday 12pm. We give will give short extensions to groups that run into trouble. But  us: Administrivia Lab 1 due Friday 12pm. We give will give short extensions to groups that run into trouble. But email us: - How much is done & left? - How much longer do you need? Attend section Friday at

More information

Background. Contiguous Memory Allocation

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

More information

Memory Management Basics

Memory Management Basics Memory Management Basics 1 Basic Memory Management Concepts Address spaces! Physical address space The address space supported by the hardware Ø Starting at address 0, going to address MAX sys! MAX sys!!

More information

CSC 369 Operating Systems

CSC 369 Operating Systems CSC 369 Operating Systems Lecture 6: Memory management Bogdan Simion Memory hierarchy 1 KB Registers Speed Price 32 128 KB L1 cache 2 8 MB L2 cache 4 16 GB DRAM 1 2 TB Disk 2 But that s not all Sequential

More information

CSE 421/521 - Operating Systems Fall Lecture - XII Main Memory Management. Tevfik Koşar. University at Buffalo. October 18 th, 2012.

CSE 421/521 - Operating Systems Fall Lecture - XII Main Memory Management. Tevfik Koşar. University at Buffalo. October 18 th, 2012. CSE 421/521 - Operating Systems Fall 2012 Lecture - XII Main Memory Management Tevfik Koşar University at Buffalo October 18 th, 2012 1 Roadmap Main Memory Management Fixed and Dynamic Memory Allocation

More information

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

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

More information

Chapter 8: Memory Management. Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging

Chapter 8: Memory Management. Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging Chapter 8: Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 1 Background Memory management is crucial in better utilizing one of the most important

More information

CS153: Memory Management 1

CS153: Memory Management 1 1 CS153: Memory Management 1 Chengyu Song Slides modified from Harsha Madhyvasta, Nael Abu-Ghazaleh, and Zhiyun Qian 2 Administrivia Lab Lab2 has been released Due Monday June 5th midnight Design document

More information

Chapter 8: Memory- Manage g me m nt n S tra r t a e t gie i s

Chapter 8: Memory- Manage g me m nt n S tra r t a e t gie i s Chapter 8: Memory- Management Strategies Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium 2009/12/16

More information

CS 153 Design of Operating Systems Winter 2016

CS 153 Design of Operating Systems Winter 2016 CS 153 Design of Operating Systems Winter 2016 Lecture 16: Memory Management and Paging Announcement Homework 2 is out To be posted on ilearn today Due in a week (the end of Feb 19 th ). 2 Recap: Fixed

More information

Frequently asked questions from the previous class survey

Frequently 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 information

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

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

More information

Fall 2017 :: CSE 306. Introduction to. Virtual Memory. Nima Honarmand (Based on slides by Prof. Andrea Arpaci-Dusseau)

Fall 2017 :: CSE 306. Introduction to. Virtual Memory. Nima Honarmand (Based on slides by Prof. Andrea Arpaci-Dusseau) Introduction to Virtual Memory Nima Honarmand (Based on slides by Prof. Andrea Arpaci-Dusseau) Motivating Virtual Memory (Very) old days: Uniprogramming only one process existed at a time OS was little

More information

CS162 Operating Systems and Systems Programming Lecture 12. Address Translation. Page 1

CS162 Operating Systems and Systems Programming Lecture 12. Address Translation. Page 1 CS162 Operating Systems and Systems Programming Lecture 12 Translation March 10, 2008 Prof. Anthony D. Joseph http://inst.eecs.berkeley.edu/~cs162 Review: Important Aspects of Memory Multiplexing Controlled

More information

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. April 12, 2018 L16-1

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. April 12, 2018 L16-1 Virtual Memory Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. L16-1 Reminder: Operating Systems Goals of OS: Protection and privacy: Processes cannot access each other s data Abstraction:

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

Main Memory: Address Translation

Main Memory: Address Translation Main Memory: Address Translation (Chapter 8) CS 4410 Operating Systems Can t We All Just Get Along? Physical Reality: different processes/threads share the same hardware à need to multiplex CPU (temporal)

More information

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

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

More information

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

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

More information

CSE 4/521 Introduction to Operating Systems. Lecture 14 Main Memory III (Paging, Structure of Page Table) Summer 2018

CSE 4/521 Introduction to Operating Systems. Lecture 14 Main Memory III (Paging, Structure of Page Table) Summer 2018 CSE 4/521 Introduction to Operating Systems Lecture 14 Main Memory III (Paging, Structure of Page Table) Summer 2018 Overview Objective: To discuss how paging works in contemporary computer systems. Paging

More information

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

CS370: 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 information

Virtual Memory I. Jo, Heeseung

Virtual Memory I. Jo, Heeseung Virtual Memory I Jo, Heeseung Today's Topics Virtual memory implementation Paging Segmentation 2 Paging Introduction Physical memory Process A Virtual memory Page 3 Page 2 Frame 11 Frame 10 Frame 9 4KB

More information

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. November 15, MIT Fall 2018 L20-1

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. November 15, MIT Fall 2018 L20-1 Virtual Memory Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. L20-1 Reminder: Operating Systems Goals of OS: Protection and privacy: Processes cannot access each other s data Abstraction:

More information

Virtual memory - Paging

Virtual memory - Paging Virtual memory - Paging Johan Montelius KTH 2017 1 / 32 The process code (.text) data heap stack kernel 0x00000000 0xC0000000 0xffffffff Memory layout for a 32-bit Linux process 2 / 32 Segments - a could

More information

The process. one problem

The process. one problem The process Virtual memory - Paging Johan Montelius code (.text) data heap stack kernel KTH 0x00000000 0xC0000000 0xffffffff 2017 Memory layout for a 32-bit Linux process Segments - a could be solution

More information

Memory Management. Memory

Memory Management. Memory Memory Management These slides are created by Dr. Huang of George Mason University. Students registered in Dr. Huang s courses at GMU can make a single machine readable copy and print a single copy of

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

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

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

More information

Chapter 8: Main Memory

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

More information

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

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

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

More information

Chapter 8: Memory- Management Strategies

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

More information

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 8: MEMORY

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 8: MEMORY I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 8: MEMORY MANAGEMENT Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the

More information

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

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

More information

Roadmap. Tevfik Koşar. CSC Operating Systems Spring Lecture - XII Main Memory - II. Louisiana State University

Roadmap. Tevfik Koşar. CSC Operating Systems Spring Lecture - XII Main Memory - II. Louisiana State University CSC 4103 - Operating Systems Spring 2007 Lecture - XII Main Memory - II Tevfik Koşar Louisiana State University March 8 th, 2007 1 Roadmap Dynamic Loading & Linking Contiguous Memory Allocation Fragmentation

More information

Chapter 8: Memory Management

Chapter 8: Memory Management Chapter 8: Memory Management Chapter 8: Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 8.2 Silberschatz, Galvin and Gagne 2005 Background Program/Code

More information

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design ECE331: Hardware Organization and Design Lecture 29: an Introduction to Virtual Memory Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Overview Virtual memory used to protect applications

More information

Chapter 8: Main Memory

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

More information

Chapter 9: Memory Management. Background

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

More information

Memory Management. 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

Memory Management Minsoo Ryu Real-Time Computing and Communications Lab. Hanyang University

Memory Management Minsoo Ryu Real-Time Computing and Communications Lab. Hanyang University Memory Management Minsoo Ryu Real-Time Computing and Communications Lab. Hanyang University msryu@hanyang.ac.kr Topics Covered Introduction Memory Allocation and Fragmentation Address Translation Paging

More information

Memory Management. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University.

Memory Management. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University. Memory Management Minsoo Ryu Real-Time Computing and Communications Lab. Hanyang University msryu@hanyang.ac.kr Topics Covered Introduction Memory Allocation and Fragmentation Address Translation Paging

More information

MEMORY: SWAPPING. Shivaram Venkataraman CS 537, Spring 2019

MEMORY: 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 information

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18 PROCESS VIRTUAL MEMORY CS124 Operating Systems Winter 2015-2016, Lecture 18 2 Programs and Memory Programs perform many interactions with memory Accessing variables stored at specific memory locations

More information

CPS 104 Computer Organization and Programming Lecture 20: Virtual Memory

CPS 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 information

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

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

More information

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

Module 8: Memory Management

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

More information

CS252 S05. Main memory management. Memory hardware. The scale of things. Memory hardware (cont.) Bottleneck

CS252 S05. Main memory management. Memory hardware. The scale of things. Memory hardware (cont.) Bottleneck Main memory management CMSC 411 Computer Systems Architecture Lecture 16 Memory Hierarchy 3 (Main Memory & Memory) Questions: How big should main memory be? How to handle reads and writes? How to find

More information

Chapter 8: Main Memory

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

More information

Main Memory. CISC3595, Spring 2015 X. Zhang Fordham University

Main Memory. CISC3595, Spring 2015 X. Zhang Fordham University Main Memory CISC3595, Spring 2015 X. Zhang Fordham University 1 Memory Management! Background!! Contiguous Memory Allocation!! Paging!! Structure of the Page Table!! Segmentation!! Example: The Intel Pentium

More information

Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation

Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Basic Hardware Address Binding Logical VS Physical Address Space Dynamic Loading Dynamic Linking and Shared

More information

Preview. Memory Management

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

More information

Chapter 8: Memory Management Strategies

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

More information

Memory: Overview. CS439: Principles of Computer Systems February 26, 2018

Memory: 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 information