3.3.1.4 Memory management Explain how memory is managed in a typical modern computer system (virtual memory, paging and segmentation should be described.

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

ITEC 352 Lecture 27 Memory(4). Review Questions? Cache control –L1/L2  Main memory example –Formulas for hits.
Memory Management Chapter 7.
Memory Management Chapter 7. Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as.
Chapter 7 Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2009, Prentice.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Memory Management Chapter 5.
Computer Organization and Architecture
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 9 – Real Memory Organization and Management Outline 9.1 Introduction 9.2Memory Organization.
1 Lecture 8: Memory Mangement Operating System I Spring 2008.
Layers and Views of a Computer System Operating System Services Program creation Program execution Access to I/O devices Controlled access to files System.
Chapter 91 Memory Management Chapter 9   Review of process from source to executable (linking, loading, addressing)   General discussion of memory.
Review of Memory Management, Virtual Memory CS448.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
Memory Management Chapter 7.
Chapter 7 Memory Management
Computer Architecture Lecture 28 Fasih ur Rehman.
Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
Memory Management – Page 1 of 49CSCI 4717 – Computer Architecture Memory Management Uni-program – memory split into two parts –One for Operating System.
Memory Management. Roadmap Basic requirements of Memory Management Memory Partitioning Basic blocks of memory management –Paging –Segmentation.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
VIRTUAL MEMORY By Thi Nguyen. Motivation  In early time, the main memory was not large enough to store and execute complex program as higher level languages.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
Memory management.
Informationsteknologi Wednesday, October 3, 2007Computer Systems/Operating Systems - Class 121 Today’s class Memory management Virtual memory.
CS6502 Operating Systems - Dr. J. Garrido Memory Management – Part 1 Class Will Start Momentarily… Lecture 8b CS6502 Operating Systems Dr. Jose M. Garrido.
Memory Management OS Fazal Rehman Shamil. swapping Swapping concept comes in terms of process scheduling. Swapping is basically implemented by Medium.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
1 Memory Management n In most schemes, the kernel occupies some fixed portion of main memory and the rest is shared by multiple processes.
Operating Systems c. define and explain the purpose of scheduling, job queues, priorities and how they are used to manage job throughput; d. explain how.
Virtual Memory (Section 9.3). The Need For Virtual Memory Many computers don’t have enough memory in RAM to accommodate all the programs a user wants.
Chapter 7 Memory Management
Memory Management Chapter 7.
Lesson Objectives Aims Key Words Paging, Segmentation, Virtual Memory
Memory Management.
Non Contiguous Memory Allocation
ITEC 202 Operating Systems
Chapter 2 Memory and process management
System Programming and administration
Chapter 9 – Real Memory Organization and Management
William Stallings Computer Organization and Architecture
Main Memory Management
Chapter 8: Main Memory.
Lecture 28: Virtual Memory-Address Translation
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
Operating System Concepts
O.S Lecture 13 Virtual Memory.
Memory Management 11/17/2018 A. Berrached:CS4315:UHD.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Multistep Processing of a User Program
Computer Architecture
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Main Memory Background Swapping Contiguous Allocation Paging
Chapter 8: Memory management
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Lecture 3: Main Memory.
CSE 451: Operating Systems Autumn 2005 Memory Management
Operating System Chapter 7. Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
COMP755 Advanced Operating Systems
Operating Systems: Internals and Design Principles, 6/E
OPERATING SYSTEMS MEMORY MANAGEMENT BY DR.V.R.ELANGOVAN.
Chapter 7 Memory Management
Presentation transcript:

3.3.1.4 Memory management Explain how memory is managed in a typical modern computer system (virtual memory, paging and segmentation should be described along with some of the problems which could occur, such as disk threshing. ICTessentials.com

Function of memory management: Memory management is the process by which a computer allocates a limited amount of physical memory, among the various processes that need it, in a way that optimises performance. Function of memory management: allocate main memory to a process or to several processes that are to be executed concurrently; allocate memory to data; protect the memory used by the operating system itself; protect processes from each other when executing concurrently – i.e. to prevent two processes from using the same memory at the same time; allow shared access to some areas of memory; free up memory when processes are unloaded – and reallocate it to new processes. Memory management is performed by the part of the operating system known as the memory management sub-system. It also deals with virtual memory, segmentation and paging

Loading a program into main memory This task is performed by a program called a loader. There are two basic types – an absolute loader and a relocating loader. Absolute loader This loads the program into a fixed area of memory. This occurs when all address references have been fixed at the time of assembly or compilation. A potential problem is that two programs may require loading into the same area of memory – this would mean that loading the second program would cause the first program to crash. An absolute loader is only effective with simple systems that run only one or two specially-written programs. Relocating loader This can load a program into any area of memory. This is possible when the program has been assembled or compiled in such a way that all addresses are relative to the start of the program. When loaded, the start address of the program is put into the a base register and all other addresses are calculated relative to this.

Virtual memory Virtual memory is the use of the backing store (i.e. hard disk), to simulate additional main memory, in order to overcome the limitations in the amount of main memory that is available. Virtual memory allows a computer to operate as if it had more memory than it actually does, but with some loss of performance. Virtual memory is necessary to: allow programs to run that need more memory than is available; allow multiple programs to run which have combined memory requirements more than the main memory available. Virtual memory will, in some way, split a program into blocks and load the blocks that are needed, when they are needed – constantly swapping blocks between main memory and the backing store. The two normal methods of splitting the programs into blocks are known as segmentation and paging.

Segmentation Segmentation is when main memory is divided into variable sized blocks called segments where each segment corresponds to a program routine (e.g. a subroutine or procedure) or a data structure/array. Each segment corresponds to a logical division of code or data, where all the code or data that is needed is contained within the segment. Each segment is protected so only routines that have the appropriate ‘permissions’ can access it. The segments may be placed anywhere in main memory, but the instructions or data in any one segment are contiguous. When a different program routine or data is needed, it is loaded as a segment and, if necessary one of the existing segments is replaced.

Segmentation

Segmentation When segments are replaced, a single segment can only be replaced by a segment of the same size or smaller. Each time a segment is replaced by one that is smaller, a small gap will be left. The accumulation of these small gaps eventually results in ‘memory fragmentation’. This makes it difficult to load large segments because there are not enough large contiguous memory locations. To overcome this fragmentation problem, segments are ‘pushed together’ occasionally to create large contiguous areas and allow large segments to be loaded. Apart from memory fragmentation, segmentation is usually very efficient because entire blocks of code are available to the processor. Also, it is easy for two processes to share the same code – if the same procedure is used by two processes concurrently, there need only be a single copy of the code segment in memory (however, each process would maintain its own, distinct data segment).

Paging Paging is when main memory is divided into fixed size blocks called page-frames and programs are divided into blocks of the same size, called pages – pages are swapped’ between the disk and the page-frames as necessary. Each frame is a physical division of memory – this can be any size, but 4 Kbytes is typical; The pages do not need to be loaded into contiguous areas of memory; A ‘Page Management Table’ stores details of which pages are loaded and where; Pages are ‘swapped’ between the disk and main memory as required – note that pages are not simply replaced, they are copied back to disk before being over-written in memory.

Paging When the OS needs a physical page frame to store a page, and there are none free, it selects one of the pages that is not currently being used and stores it back to disk. It can then use the freed page frame for the new page.

Page Management Table The Page Management Table (Page Table, PMT) maintains an index of the contents of the page frames. Each time a page is loaded, the page table is updated. As well as the page that a frame contains, some other attributes are also usually stored. For example, some pages may be characterized as read-only, read-write, etc. It is also common to include information about access privileges, to help ensure that one program does not inadvertently corrupt data for another program. It is also usual to have a bit (known as the ‘dirty’ bit) which indicates whether or not a page has been changed while in memory – if this ‘dirty’ bit is set, then the page must be written back to the disk before it is replaced by another page.

Virtual memory summary Benefits Drawbacks it allows programs to run that need more memory than is available; it allows multiple programs to run which have combined memory requirements more than the main memory available. it takes time to swap segments/pages between main memory and the hard disk – this is much slower than if the whole program were loaded into memory; in segmentation, memory becomes fragmented and so large segments cannot be loaded; in paging, memory is used for storing the page table – if the page-frames are small, the page table may take up a significant portion of memory.

Segmentation vs. Paging Similarities In practice, paging is a type of segmentation. They both: • allow programs to run when there is not enough physical (main) memory available; • provide a means by which only part of a program needs to be in memory; • split programs into blocks which are stored on disk; • split memory into blocks; • swap segments and pages between disk and memory when necessary. Differences Segmentation Paging Segments are variable in size Segments are logical divisions of code/data Segments are complete sections of programs – e.g. procedures or functions, or even complete data structures All page-frames/pages are of a fixed size Pages are physical divisions of memory Pages are made to fit sections of memory and will only contain part of the executing code/data Pages are usually smaller (4 Kbytes)

Disk threshing Disk threshing (also known as ‘thrashing) is when a high rate of disk access occurs while moving pages between memory and disk, so more time is spent on transferring pages than is spent on processing. Threshing occurs because disk access is relatively slow and pages need to be swapped regularly: when there are lots of jump routines; when there are lots of processes running – each process only has a few of its pages in memory at a time. Solutions to threshing: reduce the number of running applications; add more physical memory.