MEMORY MANAGEMENT Y. Colette Lemard. MEMORY MANAGEMENT The management of memory is one of the functions of the Operating System MEMORY = MAIN MEMORY =

Slides:



Advertisements
Similar presentations
Chapter 4 Memory Management Basic memory management Swapping
Advertisements

Part IV: Memory Management
Chapter 6: Memory Management
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.
Allocating Memory.
CS 153 Design of Operating Systems Spring 2015
Memory Management Design & Implementation Segmentation Chapter 4.
Chapter 7 Memory Management
Understanding Operating Systems1 Operating Systems Virtual Memory Thrashing Single-User Contiguous Scheme Fixed Partitions Dynamic Partitions.
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 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Memory Management Chapter 5.
Chapter 9 Virtual Memory Produced by Lemlem Kebede Monday, July 16, 2001.
Computer Organization and Architecture
Chapter 7 Memory Management
1 Lecture 8: Memory Mangement Operating System I Spring 2008.
Chapter 3 Memory Management: Virtual Memory
Review of Memory Management, Virtual Memory CS448.
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
MEMORY MANAGEMENT Presented By:- Lect. Puneet Gupta G.P.C.G. Patiala.
1. Memory Manager 2 Memory Management In an environment that supports dynamic memory allocation, the memory manager must keep a record of the usage of.
Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”
Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory.
1 Memory Management Chapter Basic memory management 4.2 Swapping (εναλλαγή) 4.3 Virtual memory (εικονική/ιδεατή μνήμη) 4.4 Page replacement algorithms.
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.
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.
Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.
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.
Operating Systems COMP 4850/CISG 5550 Basic Memory Management Swapping Dr. James Money.
Computer Systems Week 14: Memory Management Amanda Oddie.
Memory Management. Introduction To improve both the utilization of the CPU and the speed of its response to users, the computer must keep several processes.
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.
Basic Memory Management 1. Readings r Silbershatz et al: chapters
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.
Virtual Memory Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
Memory Management Chapter 5 Advanced Operating System.
Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”
Virtual Memory By CS147 Maheshpriya Venkata. Agenda Review Cache Memory Virtual Memory Paging Segmentation Configuration Of Virtual Memory Cache Memory.
Memory management The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory.
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.
Memory Management One of the most important OS jobs.
Memory Management Chapter 7.
Lesson Objectives Aims Key Words Paging, Segmentation, Virtual Memory
Memory Management.
ITEC 202 Operating Systems
Chapter 2 Memory and process management
Chapter 8: Main Memory.
Chapter 8: Main Memory.
O.S Lecture 13 Virtual Memory.
Main Memory Background Swapping Contiguous Allocation Paging
Memory Management Overview
CSE451 Memory Management Introduction Autumn 2002
CSE 451: Operating Systems Autumn 2005 Memory Management
Memory management Explain how memory is managed in a typical modern computer system (virtual memory, paging and segmentation should be described.
Memory Management (1).
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Management From the memory view, we can list four important tasks that the OS is responsible for ; To know the used and unused memory partitions To allocate.
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Operating Systems: Internals and Design Principles, 6/E
Page Main Memory.
Presentation transcript:

MEMORY MANAGEMENT Y. Colette Lemard

MEMORY MANAGEMENT The management of memory is one of the functions of the Operating System MEMORY = MAIN MEMORY = RAM

Memory Management Each process must have enough memory in which to execute A process must not encroach on the memory space of other processes nor have its memory space encroached on by other processes The different types of memory must be used properly and effectively The AIMS of memory management

Memory Management Note that as processes execute the CPU either reads data from memory or writes data to memory

Memory Management How is memory organized to facilitate these objectives?

SEGMENTATION

Memory Management Memory is partitioned into large sections of fixed sizes called segments. The segments are separated by boundaries. The segments are used for the different types of software.

Segmentation Memory is like a fixed set of slots (segments) Each segment has a unique address RAMRAM

Memory Management When the system is booted the O/S is loaded into memory first. It occupies the lower level of memory. O/S

Memory Management The drivers needed to control the hardware are next loaded into memory O/S Drivers

Segmentation The rest of the space is normally used for application programs ( user processes ). One entire process is loaded into one segment O/S Drivers Process 1 Process 2 Process 3

Segments Partitions may all be of the same size or the sizes may vary. The size(s) is(are) fixed however. They must be large enough to hold all the data for an entire process

Memory Management The O/S is responsible for : -Keeping track of which parts of memory are currently being used and by what process -Knowing which parts of memory are free -Deciding which process is to be loaded into memory when space becomes available.

Segmentation The segmentation approach sometimes causes difficulties because of the inflexibility of the partition sizes.

Segmentation Lots of space is wasted. Lots of space is wasted. Most programs do not use up the exact amount of the segment O/S Drivers Process 1 Process 2 Process 3

Segmentation -Sometimes the total of the left over space is enough for another process but it is fragmented and processes can not share partitions.

Segmentation -Segmentation therefore imposes a fixed limit on the maximum number of processes which can run at any one time => # of user segments => # of user segments

Segmentation II To counteract this the O/S can use variable partitioning Do not predetermine the sizes of the segments; give a process just the memory it needs. Do not predetermine the sizes of the segments; give a process just the memory it needs.

Segmentation II O/S Drivers Process 1 Process 2 Process 3 VARIABLY PARTITIONING Create the partition when it is needed, give just as much memory as will be required.

Segmentation In the long run this still results in holes in the memory as when a process is finished, the next process will not need the same amount as the previous one. If only a part of the memory is used by the next process, some is still left unused resulting in some fragmentation over a period of time

Segmentation A Solution – The O/S can periodically pause all tasks and compact memory so that all the free space falls in one continuous area which can be used by other processes.

Segmentation The major disadvantage of this approach is the time it takes to compact memory. Remember that this is not a user task so it takes up valuable time which could be used in constructive processing.

Memory Management For best use of the resource (memory) we therefore need another approach to managing RAM

PAGING

Paging This is an alternate approach to partitioning. Here memory is divided into very small frames as compared with segments. A single process would find that all its data cannot fit into one frame. This is an alternate approach to partitioning. Here memory is divided into very small frames as compared with segments. A single process would find that all its data cannot fit into one frame. Frames are in the order of 2 9 to 2 13 bytes in size. They are fixed in size for a particular system.

Paging The program and data therefore would also have to be partitioned so that portions of them can fit into the individual frames. The program and data therefore would also have to be partitioned so that portions of them can fit into the individual frames. The programs (and data) are said to be divided into pages. The page size would be the same as the size of the memory frames.

Memory Management Program & data pages Main memory frames

Memory Management PAGING has proven to be quite effective

Memory Management Questions ?

Memory Management Despite the best efforts of the operating system though, it sometimes finds that it needs more memory than is available because of the number and size of the processes being run.

Memory Management One solution is to add more memory to the machine This could work BUT … - memory is expensive - only a little part of the data in memory is actually being used by the CPU at any one point in time so spending more money on memory could be unnecessary

BUT … Because memory is finite, AND because the user code is broken up into pages, AND because the CPU can only operate on one page of data at a time anyway… DO WE REALLY NEED TO HAVE ALL OF A PROGRAM IN MEMORY AT ONCE?

VIRTUALMEMORY

Virtual Memory Only the pages presently being used, last used or about to be used need to be in memory. The other pages can rest in a section of the hard drive awaiting their turn.

Virtual Memory To the user it appears that the entire program is loaded into memory but it is not.. This is VIRTUAL MEMORY This is VIRTUAL MEMORY

Virtual Memory Disk space is relatively inexpensive compared to RAM. This is a better approach than adding more memory because ….

Virtual Memory Virtual memory therefore involves using a portion of the disk to extend the size of RAM.

Virtual Memory When the disk is full the O/S has less space to utilize for virtual memory. When the disk is full the O/S has less space to utilize for virtual memory. This explains why a system moves so very slowly when the hard disk is full

Question A computer uses a virtual memory management scheme with frames of 512 bytes. It has a physical memory of 16 MB. 1.How many frames does main memory have? 2.What is the size of each page? 3.If memory is fully utilized how many pages are mapped to memory?

Answers A computer uses a virtual memory management scheme with frames of 512 bytes. It has a physical memory of 16 MB. 1.How many frames does main memory have? 32 2.What is the size of each page? 2 9 Bytes 3.If memory is fully utilized how many pages are mapped to memory? 32

Virtual Memory In a virtual memory paging system, because we have some pages in RAM and some on the disk we need what is called a page table to keep track of where each page is being stored.

Virtual Memory Remember that in this system, the program could be split two ways: 1.Some pages are on the disk 2.Other pages are in scattered frames in memory

Virtual Memory When the CPU needs a particular page of data the O/S must know where to locate it (Hopefully it is in memory) The page table is used in the search

Page Table Page # Loc Loc = location

Page # Loc Program Program divided into 4 Pages Page Table31 2 Main memory

The page table is therefore searched for the particular page of interest; its location is noted and that address in main memory is accessed.

Page # Loc Program 4 Pages Page Table31 2 Main memory

The page table sometimes includes a column which indicates whether or not the page is in memory. If a page is not in memory it is accessed on the hard disk and brought into a free frame

Note that in our example one page is on the hard disk. Before the CPU can use that data it has to be brought into main memory

Page # Loc Program Program divided into 4 Pages Page Table31 2 Main memory

If main memory is full then the O/S has to begin swapping. It removes one page, stores it on the hard drive and then puts the needed page into that frame. SWAPPING

When the O/S has to spend a lot of time swapping pages from main memory to virtual memory THRASHING is said to be taking place. This reduces the efficiency of processing by slowing down execution time THRASHING

Virtual memory therefore -allows more programs to be running at a time and -Enables the execution of very large programs which can not hold in memory at one time

Segmentation Fixed partitioning Fixed partitioning Variable partitioning Paging (pages & frames) Virtual memory page tables swappingthrashing SUMMARY Topics covered

THE END