LOGICAL AND PHYSICAL ORGANIZATION MEMORY MANAGEMENT TECHNIQUES (CONT D)

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "LOGICAL AND PHYSICAL ORGANIZATION MEMORY MANAGEMENT TECHNIQUES (CONT D)"

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) 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/1 MEMORY MANAGEMENT/2 MEMORY MANAGEMENT TECHNIQUES MEMORY MANAGEMENT TECHNIQUES (CONT D) 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 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/3 MEMORY MANAGEMENT/4

2 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 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/5 MEMORY MANAGEMENT/6 DYNAMIC PARTITIONING DYNAMIC PARTITIONING (CONT D) 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 MEMORY MANAGEMENT/7

3 RELOCATION PAGING 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) 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/8 MEMORY MANAGEMENT/9 LOGICAL ADDRESS AND PAGING/SEGMENTATION LOGICAL ADDRESS AND PAGING MEMORY MANAGEMENT/10 MEMORY MANAGEMENT/11

4 SEGMENTATION LOGICAL ADDRESS AND 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 MEMORY MANAGEMENT/13 VIRTUAL MEMORY PRINCIPLE OF LOCALITY 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! 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/14 MEMORY MANAGEMENT/15

5 HARDWARE SUPPORT FOR VIRTUAL MEMORY MEMORY MANAGEMENT FORMATS 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 MEMORY MANAGEMENT/17 ADDRESS TRANSLATION TWO-LEVEL HIERARCHICAL PAGE TABLE MEMORY MANAGEMENT/18 MEMORY MANAGEMENT/19

6 ADDRESS TRANSLATION IN A TWO-LEVEL PAGING SYSTEM 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/20 MEMORY MANAGEMENT/21 TRANSLATION LOOKASIDE BUFFER (TLB) TLB ALGORITHM 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 MEMORY MANAGEMENT/23

7 ASSOCIATIVE MAPPING TLB AND CACHE 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 MEMORY MANAGEMENT/25 PAGE SIZE COMBINED PAGING AND SEGMENTATION 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 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/26 MEMORY MANAGEMENT/27

8 ADDRESS TRANSLATION 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/28 MEMORY MANAGEMENT/29 OS MEMORY MANAGEMENT SOFTWARE VIRTUAL MEMORY FETCH POLICIES 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 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/30 MEMORY MANAGEMENT/31

9 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 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/32 MEMORY MANAGEMENT/33 BASIC PAGE REPLACEMENT ALGORITHMS (CONT D) THE CLOCK REPLACEMENT ALGORITHM (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 MEMORY MANAGEMENT/35

10 COMPARISON OF PAGE REPLACEMENT ALGORITHMS 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/36 MEMORY MANAGEMENT/37 ADDITIONAL REPLACEMENT POLICIES (CONT D) LOAD CONTROL 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 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/38 MEMORY MANAGEMENT/39

11 LINUX MEMORY MANAGEMENT Two main aspects: process virtual memory and kernel memory allocation Three-level page table structure for the virtual memory 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 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 MEMORY MANAGEMENT/41 OTHER ADVANTAGES OF VIRTUAL MEMORY COPY ON WRITE 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 Before any writing takes place: MEMORY MANAGEMENT/42 MEMORY MANAGEMENT/43

12 COPY ON WRITE (CONT D) SHARED LIBRARIES As soon as Process 1 modifies Page C: MEMORY MANAGEMENT/44 MEMORY MANAGEMENT/45 MEMORY MAPPED FILES MEMORY MANAGEMENT/46

Chapter 7 Memory Management

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

More information

Operating Systems, 6 th ed. Test Bank Chapter 7

Operating Systems, 6 th ed. Test Bank Chapter 7 True / False Questions: Chapter 7 Memory Management 1. T / F In a multiprogramming system, main memory is divided into multiple sections: one for the operating system (resident monitor, kernel) and one

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

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 to ensure a reasonable supply of ready processes to consume available processor

More information

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

Memory Management. Reading: Silberschatz chapter 9 Reading: Stallings. chapter 7 EEL 602 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

Lesson 6: Memory Management & Virtualization

Lesson 6: Memory Management & Virtualization Lesson 6: Memory Management & Virtualization Contents Dynamic allocation, Memory fragmentation Paging Address translation with paging Paging hardware Page table structures Segmentation Virtual memory background

More information

Memory Management. Main memory Virtual memory

Memory Management. Main memory Virtual memory Memory Management Main memory Virtual memory Main memory Background (1) Processes need to share memory Instruction execution cycle leads to a stream of memory addresses Basic hardware CPU can only access

More information

Lecture 4: Memory Management

Lecture 4: Memory Management Lecture 4: Memory Management Background Program must be brought into memory and placed within a process for it to be run Input queue collection of processes on the disk that are waiting to be brought into

More information

Announcement. HW#3 will be posted today. Exercise # 4 will be posted on Piazza today.

Announcement. HW#3 will be posted today. Exercise # 4 will be posted on Piazza today. Announcement HW#3 will be posted today. Exercise # 4 will be posted on Piazza today. Operating Systems: Internals and Design Principles Chapter 7 Memory Management Seventh Edition William Stallings Modified

More information

CHAPTER 8 : VIRTUAL MEMORY. Introduction

CHAPTER 8 : VIRTUAL MEMORY. Introduction CHAPTER 8 : VIRTUAL MEMORY Introduction In simple paging and segmentation, we realised that we can : Load program pages or segments into frames that may not necessarily be contigous. Make memory address

More information

Memory Management. In most schemes, the kernel occupies some fixed portion of main memory and the rest is shared by multiple processes

Memory Management. In most schemes, the kernel occupies some fixed portion of main memory and the rest is shared by multiple processes Memory Management Is the task carried out by the OS and hardware to accommodate multiple processes in main memory If only a few processes can be kept in main memory, then much of the time all processes

More information

Chapter 7 Memory Management

Chapter 7 Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Chapter 7 Memory Management Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall Memory Management Subdividing

More information

Chapter 9: Virtual-Memory Management

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

More information

Chapter 7 Memory Management

Chapter 7 Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Chapter 7 Memory Management Dave Bremer Otago Polytechnic, N.Z. 2009, Prentice Hall Roadmap Basic requirements of Memory Management

More information

William Stallings Computer Organization and Architecture

William Stallings Computer Organization and Architecture William Stallings Computer Organization and Architecture Chapter 8 Operating System Support Rev. 3.2 (2009-10) by Enrico Nardelli 8-1 Objectives and Functions Convenience Making the computer easier to

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

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

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

More information

Memory Management (Ch.9)

Memory Management (Ch.9) Memory Management (Ch.9)! Background! Address Binding - Linking and Loading! Swapping! Memory Protection! Contiguous Memory Allocation! Paging! Segmentation! Combined Paging and Segmentation Silberschatz

More information

Objectives and Functions

Objectives and Functions Objectives and Functions William Stallings Computer Organization and Architecture 6 th Edition Week 10 Operating System Support Convenience Making the computer easier to use Efficiency Allowing better

More information

Chapter 10: Virtual Memory. Virtual memory. Background Demand Paging Page Replacement Allocation of Frames Thrashing Operating System Example

Chapter 10: Virtual Memory. Virtual memory. Background Demand Paging Page Replacement Allocation of Frames Thrashing Operating System Example Chapter 0: Virtual Memory Background Demand Paging Page Replacement Allocation of Frames Thrashing Operating System Example 0. Virtual memory separation of logical memory from physical memory only part

More information

Chapter 9: Virtual-Memory Management

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

More information

Operating System Concepts 7 th Edition, Feb 22, 2005

Operating System Concepts 7 th Edition, Feb 22, 2005 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. Virtual Memory

Virtual Memory. Virtual Memory Virtual Memory Gordon College Stephen Brinton Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Demand Segmentation Operating System Examples Background

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 Outline. Background Swapping Contiguous Memory Allocation Paging Segmentation Segmented Paging

Memory Management Outline. Background Swapping Contiguous Memory Allocation Paging Segmentation Segmented Paging Memory Management Outline Background Swapping Contiguous Memory Allocation Paging Segmentation Segmented Paging 1 Background Memory is a large array of bytes memory and registers are only storage CPU can

More information

CH 7. MAIN MEMORY. Base and Limit Registers. Memory-Management Unit (MMU) Chapter 7: Memory Management. Background. Logical vs. Physical Address Space

CH 7. MAIN MEMORY. Base and Limit Registers. Memory-Management Unit (MMU) Chapter 7: Memory Management. Background. Logical vs. Physical Address Space Chapter 7: Memory Management CH 7. MAIN MEMORY Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation adapted from textbook slides Background Base and Limit Registers

More information

Learning Outcomes. Memory Management

Learning Outcomes. Memory Management Learning Outcomes Memory Management Appreciate the need for memory management in operating systems, understand the limits of fixed memory allocation schemes. Understand fragmentation in dynamic memory

More information

Agenda. Memory Management. Binding of Instructions and Data to Memory. Background. CSCI 444/544 Operating Systems Fall 2008

Agenda. Memory Management. Binding of Instructions and Data to Memory. Background. CSCI 444/544 Operating Systems Fall 2008 Agenda Background Memory Management CSCI 444/544 Operating Systems Fall 2008 Address space Static vs Dynamic allocation Contiguous vs non-contiguous allocation Background Program must be brought into memory

More information

Memory Management. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum

Memory Management. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum Memory Management Yücel Saygın These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum 1 Memory Management Ideally programmers want memory that is large fast non volatile

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 2013-2014, Lecture 18 2 Programs and Memory Programs perform many interactions with memory Accessing variables stored at specific memory locations

More information

7. Memory Management

7. Memory Management Lecture Notes for CS347: Operating Systems Mythili Vutukuru, Department of Computer Science and Engineering, IIT Bombay 7. Memory Management 7.1 Basics of Memory Management What does main memory (RAM)

More information

Computer Systems Engineering Department, QUEST, Nawabshah OPERATING SYSTEMS

Computer Systems Engineering Department, QUEST, Nawabshah OPERATING SYSTEMS OPERATING SYSTEMS Memory Management Introduction Fixed Partitioning Variable Partitioning Memory Hole/Allocation management Problems Introduction Techniques to manage Main memory efficiently Provides multitasking

More information

Chapter 9: Memory Management. Background

Chapter 9: Memory Management. Background 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 it

More information

Background. Memory Management. Base and Limit Registers. Binding of Instructions and Data to Memory. Logical vs. Physical Address Space

Background. Memory Management. Base and Limit Registers. Binding of Instructions and Data to Memory. Logical vs. Physical Address Space Background Memory Management Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are only storage CPU can access directly Register access

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 Memory Management Examine basic (not virtual) memory

More information

Basic Page Replacement

Basic Page Replacement Basic Page Replacement 1. Find the location of the desired page on disk. Find a free frame: - If there is a free frame, use it - If there is no free frame, use a page replacement algorithm to select a

More information

Operating Systems Memory Management

Operating Systems Memory Management Operating Systems Memory Management ECE 344 ECE 344 Operating Systems 1 Memory Management Contiguous Memory Allocation Paged Memory Management Virtual Memory ECE 344 Operating Systems 2 Binding of Instructions

More information

3. Memory Management

3. Memory Management Principles of Operating Systems CS 446/646 3. Memory Management René Doursat Department of Computer Science & Engineering University of Nevada, Reno Spring 2006 Principles of Operating Systems CS 446/646

More information

Memory Management. memory hierarchy

Memory Management. memory hierarchy Memory Management Ideally programmers want memory that is large fast non volatile Memory hierarchy small amount of fast, expensive memory cache some medium-speed, medium price main memory gigabytes of

More information

Chapter 9: Memory Management

Chapter 9: Memory Management Chapter 9: Memory Management Background Logical versus Physical Address Space Overlays versus Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging Operating System Concepts 9.1 Background

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

Outline. V Computer Systems Organization II (Honors) (Introductory Operating Systems) (Review) Memory Management

Outline. V Computer Systems Organization II (Honors) (Introductory Operating Systems) (Review) Memory Management Outline V22.0202-001 Computer Systems Organization II (Honors) (Introductory Operating Systems) Lecture 14 Memory Management March 28, 2005 Announcements Lab 4 due next Monday (April 4 th ) demos on 4

More information

Chapter 9: Virtual-Memory Management

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

More information

Memory Management. Memory Management

Memory Management. Memory Management Memory Management Logical vs. physical address space Fragmentation Paging Segmentation Reading: Silberschatz, Ch. 8 Memory Management Observations: Process needs at least CPU and memory to run. CPU context

More information

Operating Systems Concepts

Operating Systems Concepts Operating Systems Concepts MODULE 7: MEMORY MANAGEMENT Andrzej Bednarski, Ph.D. student Department of Computer and Information Science Linköping University, Sweden E-mail: andbe@ida.liu.se URL: http://www.ida.liu.se/~andbe

More information

Virtual Memory & Memory Management

Virtual Memory & Memory Management CS 571 Operating Systems Virtual Memory & Memory Management Angelos Stavrou, George Mason University Memory Management 2 Logical and Physical Address Spaces Contiguous Allocation Paging Segmentation Virtual

More information

! Background! Demand Paging! Process Creation! Page Replacement. ! Allocation of Frames! Thrashing! Demand Segmentation! Operating System Examples

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

More information

Al-Anbar University /College of Computer Lecture Eight / Virtual Memory

Al-Anbar University /College of Computer Lecture Eight / Virtual Memory 8. Virtual Memory 8.1 Background 8.2 Demand Paging 8.3 Process Creation 8.4 Page Replacement 8.5 Allocation of Frames 8.6 Thrashing 8.7 Demand Segmentation 8.8 Examples 8.1 Background Virtual memory is

More information

Chapter 8: Memory Management!

Chapter 8: Memory Management! The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still

More information

Chapter 9 Virtual-Memory Management. Operating System Concepts Essentials 9 th Edition

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

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 Demand Segmentation Operating System Examples 10.1 Silberschatz, Galvin and Gagne 2003

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

Lectures 21 : Memory Management (ii) Thu 19 Nov 2009

Lectures 21 : Memory Management (ii) Thu 19 Nov 2009 CS211: Programming and Operating Systems Lectures 21 : Memory Management (ii) Thu 19 Nov 2009 CS211 Lectures 21 : Memory Management (ii) 1/23 This afternoon... 1 Recall... Memory management 2 Contiguous

More information

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

Chapter 9: Virtual-Memory Management. Operating System Concepts with Java 8 th Edition Chapter 9: Virtual-Memory Management Operating System Concepts with Java 8 th Edition 9.1 Silberschatz, Galvin and Gagne 2009 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement

More information

ICS Principles of Operating Systems

ICS Principles of Operating Systems ICS 143 - Principles of Operating Systems Lectures 15 and 16 - Virtual Memory Prof. Ardalan Amiri Sani Prof. Nalini Venkatasubramanian ardalan@uci.edu nalini@ics.uci.edu Virtual Memory Background Demand

More information

Section I Section Real Time Systems. Processes. 1.7 Memory Management. (Textbook: A. S. Tanenbaum Modern OS - ch. 3) Memory Management Introduction

Section I Section Real Time Systems. Processes. 1.7 Memory Management. (Textbook: A. S. Tanenbaum Modern OS - ch. 3) Memory Management Introduction EE206: Software Engineering IV 1.7 Memory Management page 1 of 28 Section I Section Real Time Systems. Processes 1.7 Memory Management (Textbook: A. S. Tanenbaum Modern OS - ch. 3) Memory Management Introduction

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 Silberschatz,

More information

CHAPTER 8 Exercises 8.1 Answer: 8.2 Answer: 8.3 Answer:

CHAPTER 8 Exercises 8.1 Answer: 8.2 Answer: 8.3 Answer: CHAPTER 8 Although many systems are demand paged (discussed in Chapter 12), there are still many that are not, and in many cases the simpler memory-management strategies may be better, especially for small

More information

III. Memory Management, Virtual Memory

III. Memory Management, Virtual Memory TDIU25: Operating Systems III. Memory Management, Virtual Memory SGG9: chapters 8 and 9 o Memory management: o contiguous allocation, fragmentation, segmentation, paging o Virtual memory: o demand paging,

More information

OPERATING SYSTEM - VIRTUAL MEMORY

OPERATING SYSTEM - VIRTUAL MEMORY OPERATING SYSTEM - VIRTUAL MEMORY http://www.tutorialspoint.com/operating_system/os_virtual_memory.htm Copyright tutorialspoint.com A computer can address more memory than the amount physically installed

More information

Operating Systems. Memory Management. Lecture 9 Michael O Boyle

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

More information

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory 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"

More information

CS 31: Intro to Systems Virtual Memory. Kevin Webb Swarthmore College April 7, 2015

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

More information

4 Main Memory Management

4 Main Memory Management 4 Main Memory Management 4.1 Introduction A large part of the OS s responsibility is organising main memory for processes. GOAL pack as many processes into memory as possible so that the processor will

More information

Module 10: Virtual Memory

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

More information

OS - Memory Management

OS - Memory Management OS - Memory Management Memory management is the functionality of an operating system which handles or manages primary memory. Memory management keeps track of each and every memory location either it is

More information

Goals of memory management. Today s desktop and server systems. Tools of memory management. A trip down Memory Lane

Goals of memory management. Today s desktop and server systems. Tools of memory management. A trip down Memory Lane Goals of memory management CSE 451: Operating Systems Spring 212 Module 11 Memory Management Allocate memory resources among competing processes, maximizing memory utilization and system throughput Provide

More information

Up until now we assumed that an entire program/process needed to be in memory to execute

Up until now we assumed that an entire program/process needed to be in memory to execute Lecture Overview Virtual memory Demand paging Page faults Page replacement Frame allocation Thrashing Operating Systems - June 7, 00 Virtual Memory Up until now we assumed that an entire program/process

More information

Introduction. Memory Management. Issues in sharing memory. Storage allocation. Transparency

Introduction. Memory Management. Issues in sharing memory. Storage allocation. Transparency Introduction The CPU fetches instructions and data of a program from memory; therefore, both the program and its data must reside in the main (RAM and ROM) memory. Memory Management Modern multiprogramming

More information

Memory Management. Operating Systems. Monoprogramming without Swapping or Paging. Multiprogramming

Memory Management. Operating Systems. Monoprogramming without Swapping or Paging. Multiprogramming Operating Systems User OS Kernel & Device Drivers Interface Programs Management Management is an important resource that needs to be managed by the OS manager is the component of the OS responsible for

More information

ICS Principles of Operating Systems

ICS Principles of Operating Systems ICS 143 - Principles of Operating Systems Operating Systems - Review of content from midterm to final Prof. Ardalan Amiri Sani Prof. Nalini Venkatasubramanian ardalan@uci.edu nalini@ics.uci.edu Deadlocks

More information

8.1 Background. Base and Limit Registers. Chapter 8: Memory-Management Management Strategies. Objectives

8.1 Background. Base and Limit Registers. Chapter 8: Memory-Management Management Strategies. Objectives Chapter 8: Memory-Management Management Strategies Objectives To provide a detailed description of various ways of organizing memory hardware To discuss various memory-management techniques, including

More information

CHAPTER 6 Memory. CMPS375 Class Notes (Chap06) Page 1 / 17 by Kuo-pao Yang

CHAPTER 6 Memory. CMPS375 Class Notes (Chap06) Page 1 / 17 by Kuo-pao Yang CHAPTER 6 Memory 6.1 Memory 313 6.2 Types of Memory 313 6.3 The Memory Hierarchy 315 6.3.1 Locality of Reference 318 6.4 Cache Memory 319 6.4.1 Cache Mapping Schemes 321 6.4.2 Replacement Policies 333

More information

Address spaces and address binding compile-time load-time run-time Memory management: mapping virtual address to physical addresses

Address spaces and address binding compile-time load-time run-time Memory management: mapping virtual address to physical addresses Outline Address spaces and address binding compile-time load-time run-time Memory management: mapping virtual address to physical addresses Paging contiguous allocation and fragmentation paging hardware

More information

Dynamic Memory Management in Hardware

Dynamic Memory Management in Hardware Dynamic Memory Management in Hardware A master thesis presented to the Mälardalens University in fulfilment of the thesis requirement for the degree of Master of Science in Electrical Engineering Västerås,

More information

Memory Management CS 447. Prof. R.K. Joshi Dept of CSE IIT Bombay

Memory Management CS 447. Prof. R.K. Joshi Dept of CSE IIT Bombay Memory Management CS 447 Prof. R.K. Joshi Dept of CSE IIT Bombay Some Simple Memory schemes Some Simple Memory schemes Some Simple Memory schemes Overlays: User level memory management (e.g. TurboPascal)

More information

OPERATING SYSTEM - MEMORY MANAGEMENT

OPERATING SYSTEM - MEMORY MANAGEMENT OPERATING SYSTEM - MEMORY MANAGEMENT http://www.tutorialspoint.com/operating_system/os_memory_management.htm Copyright tutorialspoint.com Memory management is the functionality of an operating system which

More information

Virtual Memory (Ch.10)

Virtual Memory (Ch.10) Virtual Memory (Ch.10)! Background! Demand Paging! Page Faults! Page Replacement! Page Replacement Algorithms! Thrashing! Strategies for Thrashing Prevention Silberschatz / OS Concepts / 6e - Chapter 10

More information

Contiguous Allocation. Contiguous Allocation. Free List. Dynamic Storage-Allocation Problem. Fragmentation

Contiguous Allocation. Contiguous Allocation. Free List. Dynamic Storage-Allocation Problem. Fragmentation Contiguous Allocation Main memory usually into two partitions: Resident operating system, usually held in low memory with interrupt vector. User processes then held in high memory. Memory Management --

More information

Main Memory. Memory. Address binding. Memory spaces. All processes need main memory.

Main Memory. Memory. Address binding. Memory spaces. All processes need main memory. Memory If we define memory as a place where data is stored there are many levels of memory: Processor registers Primary (or main) memory RAM Secondary memory slower and more permanent disks Tertiary memory

More information

Memory Management. Prof. P.C.P. Bhatt. P.C.P Bhat OS/M4/V1/2004 1

Memory Management. Prof. P.C.P. Bhatt. P.C.P Bhat OS/M4/V1/2004 1 Memory Management Prof. P.C.P. Bhatt P.C.P Bhat OS/M4/V1/2004 1 What is a Von-Neumann Architecture? Von Neumann computing requires a program to reside in main memory to run. Motivation The main motivation

More information

Memory Management and Paging. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han

Memory Management and Paging. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han Announcements PA #2 due Friday March 18 11:55 pm - note extension of a day Read chapters 11 and 12 From last time...

More information

Module 4: Memory Management

Module 4: Memory Management Module 4: Memory Management The von Neumann principle for the design and operation of computers requires that a program has to be primary memory resident to execute. Also, a user requires to revisit his

More information

Memory management basics (1) Requirements (1) Objectives. Operating Systems Part of E1.9 - Principles of Computers and Software Engineering

Memory management basics (1) Requirements (1) Objectives. Operating Systems Part of E1.9 - Principles of Computers and Software Engineering Memory management basics (1) Requirements (1) Operating Systems Part of E1.9 - Principles of Computers and Software Engineering Lecture 7: Memory Management I Memory management intends to satisfy the following

More information

Paging & Segmentation

Paging & Segmentation & Frédéric Haziza Department of Computer Systems Uppsala University Spring 2007 Outline 1 Paging Implementation Protection Sharing 2 Setup Implementation Definition Paging Memory-management

More information

CSE 380 Computer Operating Systems. Instructor: Insup Lee. University of Pennsylvania, Fall 2002 Lecture Note: Memory Management.

CSE 380 Computer Operating Systems. Instructor: Insup Lee. University of Pennsylvania, Fall 2002 Lecture Note: Memory Management. CSE 380 Computer Operating Systems Instructor: Insup Lee University of Pennsylvania, Fall 2002 Lecture Note: Memory Management 1 Memory Management q The memory management portion of the Operating System

More information

ECE 4750 Computer Architecture. T16: Address Translation and Protection

ECE 4750 Computer Architecture. T16: Address Translation and Protection ECE 4750 Computer Architecture Topic 16: Translation and Protection Christopher Batten School of Electrical and Computer Engineering Cornell University! http://www.csl.cornell.edu/courses/ece4750! ECE

More information

Memory Management: Main Memory

Memory Management: Main Memory Memory Management: Main Memory It s all about bookkeeping The von Neumann model: fetch instructions from memory; decode instructions; possibly read or write data to or from memory; rinse and repeat In

More information

CSE 513 Introduction to Operating Systems. Class 7 - Virtual Memory (2)

CSE 513 Introduction to Operating Systems. Class 7 - Virtual Memory (2) CSE 513 Introduction to Operating Systems Class 7 - Virtual Memory (2) Jonathan Walpole Dept. of Comp. Sci. and Eng. Oregon Health and Science University Key memory management issues Utilization Programmability

More information

An Introduction to Memory Management: appendix. Copyright : University of Illinois CS 241 Staff 1

An Introduction to Memory Management: appendix. Copyright : University of Illinois CS 241 Staff 1 An Introduction to Memory Management: appendix Copyright : University of Illinois CS 241 Staff 1 Memory partitioning Nowadays memory management is based on a sophisticated technique known as (paged) virtual

More information

Operating Systems Concepts: Chapter 8: Memory Management

Operating Systems Concepts: Chapter 8: Memory Management Operating Systems Concepts: Chapter 8: Memory Management Olav Beckmann Huxley 449 http://www.doc.ic.ac.uk/~ob3 Acknowledgements: There are lots. See end of Chapter 1. Home Page for the course: http://www.doc.ic.ac.uk/~ob3/teaching/operatingsystemsconcepts/

More information

COSC243 Part 2: Operating Systems

COSC243 Part 2: Operating Systems COSC243 Part 2: Operating Systems Lecture 20: Main Memory Management Zhiyi Huang Dept. of Computer Science, University of Otago Zhiyi Huang (Otago) COSC243 Lecture 20 1 / 29 O/S/ course overview Introduction

More information

PROJECT REPORT MEMORY MANAGEMENT DATE :

PROJECT REPORT MEMORY MANAGEMENT DATE : PROJECT REPORT MEMORY MANAGEMENT DATE : GROUP MEMBERS: MEMORY MANAGEMENT PURPOSE: To simulate memory management of a simple system in order to better comprehend the complex memory management system of

More information

Performance Example memory access time = 100 nanoseconds swap fault overhead = 25 msec page fault rate = 1/1000 EAT = (1-p) * p * (25 msec)

Performance Example memory access time = 100 nanoseconds swap fault overhead = 25 msec page fault rate = 1/1000 EAT = (1-p) * p * (25 msec) Memory Management Outline Operating Systems Processes Memory Management Basic Paging Virtual memory Virtual Memory Motivation Demand Paging Logical address space larger than physical memory Virtual Memory

More information

Memory Management. Overview

Memory Management. Overview Memory Management 1 Overview Basic memory management Address Spaces Virtual memory Page replacement algorithms Design issues for paging systems Implementation issues Segmentation 2 1 Memory Management

More information

Operating Systems. Virtual Memory

Operating Systems. Virtual Memory Operating Systems Virtual Memory Virtual Memory Topics. Memory Hierarchy. Why Virtual Memory. Virtual Memory Issues. Virtual Memory Solutions. Locality of Reference. Virtual Memory with Segmentation. Page

More information

Lecture 17: Paging Mechanisms

Lecture 17: Paging Mechanisms Operating Systems (A) (Honor Track) Lecture 17: Paging Mechanisms Tao Wang School of Electronics Engineering and Computer Science http://ceca.pku.edu.cn/wangtao Fall 2013 Acknowledgements: Prof. Xiangqun

More information

Memory Management. Today. Next Time. ! Basic memory management! Swapping! Kernel memory allocation. ! Virtual memory

Memory Management. Today. Next Time. ! Basic memory management! Swapping! Kernel memory allocation. ! Virtual memory Memory Management Today! Basic memory management! Swapping! Kernel memory allocation Next Time! Virtual memory Memory management! Ideal memory for a programmer Large Fast Non volatile Cheap! Nothing like

More information

CS5460: Operating Systems Lecture 16: Page Replacement (Ch. 9)

CS5460: Operating Systems Lecture 16: Page Replacement (Ch. 9) CS5460: Operating Systems Lecture 16: Page Replacement (Ch. 9) Last Time: Demand Paging Key idea: RAM is used as a cache for disk Don t give a process a page of RAM until it is needed When running short

More information

Virtual and Physical Addresses

Virtual and Physical Addresses Virtual and Physical Addresses Physical addresses are provided by the hardware: one physical address space per machine; valid addresses are usually between 0 and some machinespecific maximum; not all addresses

More information