MEMORY MANAGEMENT/1 CS 409, FALL 2013

Size: px
Start display at page:

Download "MEMORY MANAGEMENT/1 CS 409, FALL 2013"

Transcription

1 MEMORY MANAGEMENT Requirements: Relocation (to different memory areas) Protection (run time, usually implemented together with relocation) Sharing (and also protection) Logical organization Physical organization Key terms: Frame a fixed-size block of the main memory Page a fixed-size block of data (secondary memory) A page may temporarily be copied into a frame Segment a variable-size block of data (secondary memory) An entire segment may temporarily be copied into the main memory (segmentation) or the segment may be divided into pages which can be individually copied into the main memory (combined segmentation and paging) MEMORY MANAGEMENT/1

2 LOGICAL AND PHYSICAL ORGANIZATION Logical organization is linear Different parts of the memory can have different permissions (read-write, read-only, etc.) Best implemented using segmentation Physical organization cannot be linear Cannot leave the responsibility of managing memory to the programmer Memory requirements may exceed physical memory, are unknown at build time anyway MEMORY MANAGEMENT/2

3 MEMORY MANAGEMENT TECHNIQUES External fragmentation = memory exists to satisfy a request, but is not contiguous Internal fragmentation = allocated memory may be slightly larger than requested memory; difference not used Fixed Partitioning: Main memory is divided into a number of static partitions; a process may be loaded into a partition of equal or greater size Simple to implement, but inefficient (internal fragmentation) Maximum number of active processes is fixed Dynamic Partitioning: Partitions are created dynamically, so that each process is loaded into a partition of exactly the same size as that process No internal fragmentation, more efficient use of main memory Need for compaction to counter external fragmentation (increased CPU load) Simple Paging: Main memory divided into a number of equal-size frames; each process is divided into a number of equal-size pages (same size as frames); a process is loaded by loading all of its pages into available, not necessarily contiguous, frames No external fragmentation; some (small) internal fragmentation MEMORY MANAGEMENT/3

4 MEMORY MANAGEMENT TECHNIQUES (CONT D) Simple Segmentation: Process divided into a number of segments; process is loaded by loading all of its segments into dynamic partitions (need not be contiguous) No internal fragmentation, improved memory utilization, reduced overhead vs. dynamic partitioning External fragmentation Virtual Memory Paging: As with simple paging, except that it is not necessary to load all of the pages of a process; nonresident pages are brought in later, as needed No external fragmentation, higher degree of multiprogramming, large virtual address space Overhead of complex memory management Virtual Memory Segmentation: As with simple segmentation, but is not necessary to load all of the segments; nonresident segments are brought in later, as needed No internal fragmentation, higher degree of multiprogramming, large virtual address space, protection and sharing support Overhead of complex memory management MEMORY MANAGEMENT/4

5 PARTITIONING Same-size partitions All programs occupy the same amount of space no matter their size = inefficient, internal fragmentation (whenever program data smaller than partition size) Unequal size partitions Existence of smaller partitions reduce the internal fragmentation Memory assignment: queues of processes waiting to be brought into main memory A single queue or one queue per partition size The fixed number of partitions limits the number of active processes in the system Small jobs will not utilize partition space efficiently Programs larger than any partition loaded via overlays OS can only swap out whole processes if needed MEMORY MANAGEMENT/5

6 DYNAMIC PARTITIONING Process is allocated exactly as much memory as it requires = partitions of variable length and number Used by IBM s mainframe operating system OS/MVT Placement algorithms: Best-fit: chooses the block that is closest in size to the request First-fit: first block that is large enough Next-fit: next large enough block since the last allocation Main disadvantage: external fragmentation Memory utilization declines as memory becomes more and more fragmented Solution: compacting = OS shifts processes in memory so that they are contiguous and free memory is in one block; costly MEMORY MANAGEMENT/6

7 DYNAMIC PARTITIONING Process is allocated exactly as much memory as it requires = partitions of variable length and number Used by IBM s mainframe operating system OS/MVT Placement algorithms: Best-fit: chooses the block that is closest in size to the request First-fit: first block that is large enough Next-fit: next large enough block since the last allocation Main disadvantage: external fragmentation Memory utilization declines as memory becomes more and more fragmented Solution: compacting = OS shifts processes in memory so that they are contiguous and free memory is in one block; costly MEMORY MANAGEMENT/6

8 DYNAMIC PARTITIONING (CONT D) MEMORY MANAGEMENT/7

9 RELOCATION Logical address = reference to memory location independent on the assignment of data to memory Relative address = address expressed as a location relative to some known point Physical/Absolute address: actual location in main memory Relocation: Logical address relative (to the beginning of the process) address physical address Needs hardware support = Memory Management Unit (MMU) MEMORY MANAGEMENT/8

10 PAGING Partition memory into equal fixed-size chunks that are relatively small (pages) Process is also divided into small fixed-size chunks of the same size (frames) Key data structure: page table Maintained by operating system for each process Contains the frame location for each page in the process Processor must know how to access for the current process Used by processor to produce a physical address MEMORY MANAGEMENT/9

11 LOGICAL ADDRESS AND PAGING/SEGMENTATION MEMORY MANAGEMENT/10

12 LOGICAL ADDRESS AND PAGING MEMORY MANAGEMENT/11

13 SEGMENTATION A program can be subdivided into segments May vary in length Maximum length usually given Addressing consists of two parts: Segment number Offset Similar to dynamic partitioning Eliminates internal fragmentation MEMORY MANAGEMENT/12

14 LOGICAL ADDRESS AND SEGMENTATION MEMORY MANAGEMENT/13

15 VIRTUAL MEMORY Not necessary that all the process is in memory as long as all references are logical addresses and address space can be split into pages OS brings into main memory a few pieces of the program = resident set An interrupt is generated when an address is needed but is in the virtual memory (usually on disk) instead of the main memory OS places the process in a Blocked state while the missing piece is brought into the main memory Operating system issues a disk I/O Read request (usually) Another process is dispatched to run while the disk I/O takes place When disk I/O is complete (interrupt), the affected process is placed back in the Ready state More processes can be maintained in the main memory Only some of the pieces of each process are loaded With so many processes in main memory it is very likely a process will be in the Ready state at any particular time A process can even be larger than all of the main memory! MEMORY MANAGEMENT/14

16 PRINCIPLE OF LOCALITY Main problem: Thrashing = the system spends most of its time swapping process pieces rather than executing instructions To avoid this, the OS tries to guess based on recent history which pieces are least likely to be used in the near future Guess is based on the principle of locality Program and data references within a process tend to cluster Only a few pieces of a process will be needed over a short period of time Therefore it is possible to make intelligent guesses about which pieces will be needed in the future MEMORY MANAGEMENT/15

17 HARDWARE SUPPORT FOR VIRTUAL MEMORY Hardware must support paging and segmentation OS must include software for managing the movement of pages and/or segments between secondary memory and main memory Virtual memory is usually associated with systems that employ paging Each process has its own page table Each page table entry contains the frame number of the corresponding page in main memory MEMORY MANAGEMENT/16

18 MEMORY MANAGEMENT FORMATS MEMORY MANAGEMENT/17

19 ADDRESS TRANSLATION MEMORY MANAGEMENT/18

20 TWO-LEVEL HIERARCHICAL PAGE TABLE MEMORY MANAGEMENT/19

21 ADDRESS TRANSLATION IN A TWO-LEVEL PAGING SYSTEM MEMORY MANAGEMENT/20

22 INVERTED PAGE TABLE Page number portion of a virtual address is mapped into a hash value Hash value points to inverted page table Fixed proportion of real memory is required for the tables regardless of the number of processes or virtual pages supported Structure is called inverted because it indexes page table entries by frame number rather than by virtual page number MEMORY MANAGEMENT/21

23 TRANSLATION LOOKASIDE BUFFER (TLB) Problem: Each virtual memory reference can cause two physical memory accesses: one to fetch the page table entry one to fetch the data Solution: use a special highspeed cache called a translation lookaside buffer MEMORY MANAGEMENT/22

24 TLB ALGORITHM MEMORY MANAGEMENT/23

25 ASSOCIATIVE MAPPING TLB cannot be indexed on page number (it contains only some page table entries) TLB entry must include the page number as well as the complete page table entry Hardware that allows simultaneously interrogation of a number of TLB entries to determine if there is a match on page number = associative mapping MEMORY MANAGEMENT/24

26 TLB AND CACHE MEMORY MANAGEMENT/25

27 PAGE SIZE The smaller the page size, the lesser the amount of internal fragmentation However, more pages are required per process More pages per process means larger page tables For large programs in a heavily multiprogrammed environment some portion of the page tables of active processes must be in virtual memory instead of main memory The physical characteristics of most secondary-memory devices favor a larger page size for more efficient block transfer of data Computer Atlas Honeywell-Multics IBM 370/XA IBM 370/ESA VAX family IBM AS/400 DEC Alpha MIPS UltraSPARC Pentium IBM POWER Itanium Page Size bit words bit words 4 KB 512 bytes 512 bytes 8 KB 4 KB to 16 MB 8 KB to 4 MB 4 KB or 4 MB 4 KB 4 KB to 256 MB MEMORY MANAGEMENT/26

28 COMBINED PAGING AND SEGMENTATION Segmentation allows programmer to view memory as consisting of multiple address spaces (or segments) Simplifies handling of large data structures Facilitates sharing data among processes Facilitates protection Each segment table entry contains the starting address of the corresponding segment in main memory and the length of the segment A bit is needed to determine if the segment is already in main memory Another bit is needed to determine if the segment has been modified since it was loaded in main memory In a combined paging/segmentation system a user s address space is broken up into a number of segments Each segment is broken up into a number of fixed-sized pages which are equal in length to a main memory frame Segmentation is visible to the programmer, paging is transparent MEMORY MANAGEMENT/27

29 ADDRESS TRANSLATION MEMORY MANAGEMENT/28

30 PROTECTION RELATIONSHIP Segmentation lends itself to the implementation of protection and sharing policies Each entry has a base address and length so inadvertent memory access can be controlled Sharing can be achieved by segments referencing multiple processes Each entry in segment table features: Validation bit (0 = illegal segment) Read/write/execute privileges MEMORY MANAGEMENT/29

31 OS MEMORY MANAGEMENT SOFTWARE The design of the memory management portion of an operating system depends on three fundamental areas of choice: Whether or not to use virtual memory techniques The use of paging or segmentation or both The algorithms employed for various aspects of memory management MEMORY MANAGEMENT/30

32 VIRTUAL MEMORY FETCH POLICIES Fetch policy: Determines when a page should be brought into memory Demand paging only brings pages into main memory when a reference is made to a location on the page Many page faults when process is first started But drops as more and more pages are brought in (principle of locality most future references will be to pages that have recently been brought in) Prepaging once a page is demanded, more are brought in Exploits the characteristics of most secondary memory devices If pages of a process are stored contiguously in secondary memory it is more efficient to bring in a number of pages at one time Ineffective if extra pages are not referenced MEMORY MANAGEMENT/31

33 VIRTUAL MEMORY PLACEMENT AND REPLACEMENT POLICIES Placement determines where in real memory a process piece is to reside Important design issue in a segmentation system But irrelevant to paging or combined paging with segmentation (hardware performs functions with equal efficiency) Replacement deals with the selection of a page in main memory to be replaced when a new page must be brought in Objective: the page that is removed is the page least likely to be referenced in the near future The more elaborate the better at guessing, but at the cost of greater hardware and software overhead Frame Locking: When a frame is locked the page currently stored in that frame may not be replaced The kernel as well as key control structures are held in locked frames I/O buffers and time-critical areas may be locked into main memory frames Achieved by associating a lock bit with each frame MEMORY MANAGEMENT/32

34 BASIC PAGE REPLACEMENT ALGORITHMS Optimal: Selects page for which the time to the next reference is the longest (ideal) Least Recently Used (LRU): Replaces the page that has not been referenced for the longest time Principle of locality LRU = page least likely to be referenced in the near future Difficult to implement, substantial overhead One approach is to tag each page with the time of last reference MEMORY MANAGEMENT/33

35 BASIC PAGE REPLACEMENT ALGORITHMS (CONT D) First-in-First-out (FIFO): Treats page frames allocated to a process as a circular buffer; pages are removed in round-robin style Simple to implement, page that has been in memory the longest is replaced Clock: Associates a use bit with each frame, initialized with 1 on load Any frame with a use bit of 1 is passed over by the algorithm (but the bit is reset) Page frames visualized as laid out in a circle MEMORY MANAGEMENT/34

36 THE CLOCK REPLACEMENT ALGORITHM (CONT D) MEMORY MANAGEMENT/35

37 COMPARISON OF PAGE REPLACEMENT ALGORITHMS MEMORY MANAGEMENT/36

38 ADDITIONAL REPLACEMENT POLICIES Page buffering: A replaced page is assigned to the free page list or modified page list (as the case might be) Pages are written to disk in clusters to improve efficiency Replacement Policy and Cache Size: With large caches replacement of pages can have a performance impact; if the page frame to be replaced is in the cache then that cache block is lost as well Resident Set Management: The OS must decide how many pages to bring into main memory The smaller the amount of memory allocated to each process, the more processes can reside in memory But small number of pages loaded increases page faults But beyond a certain size further allocation of pages will not effect page fault rate Fixed-allocation gives a process a fixed number of frames in main memory within which to execute (page fault one of the pages of that process is replaced) Variable-allocation allows the number of frames allocated to a process to vary MEMORY MANAGEMENT/37

39 ADDITIONAL REPLACEMENT POLICIES (CONT D) Replacement Scope Local: chooses only among the resident pages of the process that generated the page fault Global: considers all unlocked pages in main memory (not possible for fixed allocation) Most used policy: variable allocation, global scope Cleaning policy: determine when a modified page should be written out to secondary memory Demand Cleaning: a page is written out only when it has been selected for replacement Precleaning: allows the writing of pages in batches MEMORY MANAGEMENT/38

40 LOAD CONTROL Determines the number of processes that will be resident in main memory Critical in effective memory management Too few processes, many occasions when all processes will be blocked and much time will be spent in swapping Too many processes will lead to thrashing If the degree of multiprogramming is to be reduced, one or of the currently resident processes must be swapped out; six possibilities exist: Lowest-priority process Faulting process Last process activated Process with the smallest resident set Largest process Process with the largest remaining execution window Do not confuse swapping with page replacement! MEMORY MANAGEMENT/39

41 LINUX MEMORY MANAGEMENT Two main aspects: process virtual memory and kernel memory allocation Three-level page table structure for the virtual memory Page replacement based on the clock algorithm, with an 8-bit age variable (incremented each time a page is accessed, decremented periodically) An age of 0 not accessed in a long time, best candidate for replacement (LRU) MEMORY MANAGEMENT/40

42 KERNEL MEMORY ALLOCATION IN LINUX Page allocator inefficient because the kernel usually requires small chunks in odd sizes A buddy algorithm (power-of-two allocator) and slab allocation are used so that memory for the kernel can be allocated and deallocated in units of one or more pages MEMORY MANAGEMENT/41

43 OTHER ADVANTAGES OF VIRTUAL MEMORY Process creation: Copy-on-write (COW) Allows both parent and child processes to initially share the same pages If either process modifies a shared page, only then is the page copied Allows more efficient process creation as only modified pages are copied Memory-mapped files Memory-mapped file I/O allows file I/O to be treated as routine memory access by mapping a disk block to a page in memory A file is initially read using demand paging. A page-sized portion of the file is read from the file system into a physical page. Subsequent reads/writes to/from the file are treated as ordinary memory accesses. Simplifies file access by treating file I/O through memory rather than read() and write() system calls Also allows several processes to map the same file allowing the pages in memory to be shared Mapping of shared libraries MEMORY MANAGEMENT/42

44 COPY ON WRITE Before any writing takes place: MEMORY MANAGEMENT/43

45 COPY ON WRITE (CONT D) As soon as Process 1 modifies Page C: MEMORY MANAGEMENT/44

46 SHARED LIBRARIES MEMORY MANAGEMENT/45

47 MEMORY MAPPED FILES MEMORY MANAGEMENT/46

ECE519 Advanced Operating Systems

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

More information

Chapter 8 Virtual Memory

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

More information

Chapter 8 Virtual Memory

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

More information

Chapter 8 Virtual Memory

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

More information

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

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

More information

Memory Management Virtual Memory

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

More information

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

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

More information

Chapter 8. Virtual Memory

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

More information

Virtual Memory. Chapter 8

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

More information

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

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

More information

Chapter 7 Memory Management

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

More information

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

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

More information

Virtual Memory. control structures and hardware support

Virtual Memory. control structures and hardware support Virtual Memory control structures and hardware support 1 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time A process may be swapped in and

More information

Memory Management Virtual Memory

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

More information

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

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

More information

Role of OS in virtual memory management

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

More information

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

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

More information

Operating System Concepts

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

More information

Chapter 9: Virtual Memory

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

More information

Chapters 9 & 10: Memory Management and Virtual Memory

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

More information

First-In-First-Out (FIFO) Algorithm

First-In-First-Out (FIFO) Algorithm First-In-First-Out (FIFO) Algorithm Reference string: 7,0,1,2,0,3,0,4,2,3,0,3,0,3,2,1,2,0,1,7,0,1 3 frames (3 pages can be in memory at a time per process) 15 page faults Can vary by reference string:

More information

Virtual Memory Outline

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

More information

Memory Management. Memory Management

Memory Management. Memory Management Memory Management Chapter 7 1 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as many processes into memory as possible 2 1 Memory

More information

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

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization Requirements Relocation Memory management ability to change process image position Protection ability to avoid unwanted memory accesses Sharing ability to share memory portions among processes Logical

More information

Virtual Memory. Reading: Silberschatz chapter 10 Reading: Stallings. chapter 8 EEL 358

Virtual Memory. Reading: Silberschatz chapter 10 Reading: Stallings. chapter 8 EEL 358 Virtual Memory Reading: Silberschatz chapter 10 Reading: Stallings chapter 8 1 Outline Introduction Advantages Thrashing Principal of Locality VM based on Paging/Segmentation Combined Paging and Segmentation

More information

Chapter 9: Virtual Memory

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

More information

Chapter 8: Virtual Memory. Operating System Concepts

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

More information

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

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

More information

Chapter 9: Virtual Memory

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

More information

Virtual Memory. Chapter 8

Virtual Memory. Chapter 8 Chapter 8 Virtual Memory What are common with paging and segmentation are that all memory addresses within a process are logical ones that can be dynamically translated into physical addresses at run time.

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

COMP 346 WINTER 2018 MEMORY MANAGEMENT (VIRTUAL MEMORY)

COMP 346 WINTER 2018 MEMORY MANAGEMENT (VIRTUAL MEMORY) COMP 346 WINTER 2018 1 MEMORY MANAGEMENT (VIRTUAL MEMORY) VIRTUAL MEMORY A process may be broken up into pieces (pages or segments) that do not need to be located contiguously in main memory. Memory references

More information

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

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

More information

OPERATING SYSTEM. Chapter 9: Virtual Memory

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

More information

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

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

More information

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

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

More information

Memory Management. Memory Management Requirements

Memory Management. Memory Management Requirements Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable supply of ready processes to consume available processor time 1 Memory Management

More information

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

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

More information

Basic Memory Management

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

More information

Chapter 10: Virtual Memory. Background

Chapter 10: Virtual Memory. Background Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples 10.1 Background Virtual memory separation of user logical

More information

Chapter 8. Operating System Support. Yonsei University

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

More information

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

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

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

More information

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

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

More information

Chapter 10: Virtual Memory. Background. Demand Paging. Valid-Invalid Bit. Virtual Memory That is Larger Than Physical Memory

Chapter 10: Virtual Memory. Background. Demand Paging. Valid-Invalid Bit. Virtual Memory That is Larger Than Physical Memory Chapter 0: Virtual Memory Background Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples Virtual memory separation of user logical memory

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

Virtual Memory COMPSCI 386

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

More information

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

Operating Systems Lecture 6: Memory Management II

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

More information

Chapter 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

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

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

Week 2: Tiina Niklander

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

More information

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 3: Virtual Memory ว ตถ ประสงค. Background สามารถอธ บายข อด ในการท ระบบใช ว ธ การจ ดการหน วยความจ าแบบเสม อนได

Chapter 3: Virtual Memory ว ตถ ประสงค. Background สามารถอธ บายข อด ในการท ระบบใช ว ธ การจ ดการหน วยความจ าแบบเสม อนได Chapter 9: Virtual Memory Chapter 3: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations

More information

Operating System Support

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

More information

Chapter 4 Memory Management

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

More information

Memory Management and Protection

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

More information

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

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

More information

Operating Systems, Fall

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

More information

Optimal Algorithm. Replace page that will not be used for longest period of time Used for measuring how well your algorithm performs

Optimal Algorithm. Replace page that will not be used for longest period of time Used for measuring how well your algorithm performs Optimal Algorithm Replace page that will not be used for longest period of time Used for measuring how well your algorithm performs page 1 Least Recently Used (LRU) Algorithm Reference string: 1, 2, 3,

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

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

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

More information

Chapter 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 william stallings, maurizio pizzonia - sistemi operativi

Memory Management william stallings, maurizio pizzonia - sistemi operativi Memory Management 1 summary goals and requirements techniques that do not involve virtual memory 2 memory management tracking used and free memory primitives allocation of a certain amount of memory de-allocation

More information

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

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

More information

Operating System Concepts 9 th Edition

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

More information

Chapter 9: Virtual Memory. Operating System Concepts 9th Edition

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

More information

Chapter 4 Memory Management. Memory Management

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

More information

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

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

More information

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

Chapter 10: Virtual Memory

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

More information

Where are we in the course?

Where are we in the course? Previous Lectures Memory Management Approaches Allocate contiguous memory for the whole process Use paging (map fixed size logical pages to physical frames) Use segmentation (user s view of address space

More information

Demand Paging. Valid-Invalid Bit. Steps in Handling a Page Fault. Page Fault. Transfer of a Paged Memory to Contiguous Disk Space

Demand Paging. Valid-Invalid Bit. Steps in Handling a Page Fault. Page Fault. Transfer of a Paged Memory to Contiguous Disk Space Demand Paging Transfer of a Paged Memory to Contiguous Disk Space Bring a page into memory only when it is needed. Less I/O needed Less memory needed Faster response More users Page is needed reference

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

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 23 Virtual memory Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Is a page replaces when

More information

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition

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

More information

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

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

More information

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

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

More information

Chapter 8: Memory Management

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

More information

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

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

More information

CS450/550 Operating Systems

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

More information

Perform page replacement. (Fig 8.8 [Stal05])

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

More information

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

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

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

stack Two-dimensional logical addresses Fixed Allocation Binary Page Table

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

More information

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

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

More information

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

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

More information

Lecture 7. Memory Management

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

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

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

More information

Virtual Memory: Page Replacement. CSSE 332 Operating Systems Rose-Hulman Institute of Technology

Virtual Memory: Page Replacement. CSSE 332 Operating Systems Rose-Hulman Institute of Technology Virtual Memory: Page Replacement CSSE 332 Operating Systems Rose-Hulman Institute of Technology Announcements Project E & presentation are due Wednesday Team reflections due Monday, May 19 The need for

More information

Module 8: Memory Management

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

More information

CPE300: Digital System Architecture and Design

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

More information

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

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

More information

Memory Management. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Memory Management. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University Memory Management Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Topics Why is memory management difficult? Old memory management techniques: Fixed

More information

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

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

More information

VII. Memory Management

VII. Memory Management VII. Memory Management 1 Intended Schedule Date Lecture Hand out Submission 0 20.04. Introduction to Operating Systems Course registration 1 27.04. Systems Programming using C (File Subsystem) 1. Assignment

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

Virtual Memory III. Jo, Heeseung

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

More information

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory Chapter 9: Virtual Memory Chapter 9: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Demand Segmentation Operating System Examples 9.2 Background

More information