Computer Systems 2009-2010 Week 14: Memory Management Amanda Oddie.

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

Operating System Support Focus on Architecture
Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
Multiprocessing Memory Management
CS 104 Introduction to Computer Science and Graphics Problems
Memory Management 2010.
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.
Chapter 9 Virtual Memory Produced by Lemlem Kebede Monday, July 16, 2001.
Computer Organization and Architecture
Virtual Memory Deung young, Moon ELEC 5200/6200 Computer Architecture and Design Lectured by Dr. V. Agrawal Lectured by Dr. V.
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 9 – Real Memory Organization and Management Outline 9.1 Introduction 9.2Memory Organization.
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Operating Systems Brian Farrimond. Topics Introduction Overview of operating system tasks Operating systems in detail.
CS364 CH08 Operating System Support TECH Computer Science Operating System Overview Scheduling Memory Management Pentium II and PowerPC Memory Management.
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.
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Tutorial 6 Memory Management
Chapter 3 Memory Management: Virtual Memory
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
Computers in the real world Objectives Understand what is meant by memory Difference between RAM and ROM Look at how memory affects the performance of.
Tutorial 7 Memory Management presented by: Antonio Maiorano Paul Di Marco.
Review of Memory Management, Virtual Memory CS448.
MEMORY MANAGEMENT Presented By:- Lect. Puneet Gupta G.P.C.G. Patiala.
Chapter 5 Operating System Support. Outline Operating system - Objective and function - types of OS Scheduling - Long term scheduling - Medium term scheduling.
Chapter 4 Storage Management (Memory Management).
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.
6 Memory Management and Processor Management Management of Resources Measure of Effectiveness – On most modern computers, the operating system serves.
OPERATING SYSTEMS Lecture 3: we will explore the role of the operating system in a computer Networks and Communication Department 1.
Chapter 4 Memory Management Virtual Memory.
Memory Management Fundamentals Virtual Memory. Outline Introduction Motivation for virtual memory Paging – general concepts –Principle of locality, demand.
Virtual Memory Virtual Memory is created to solve difficult memory management problems Data fragmentation in physical memory: Reuses blocks of memory.
1 Memory Management. 2 Fixed Partitions Legend Free Space 0k 4k 16k 64k 128k Internal fragmentation (cannot be reallocated) Divide memory into n (possible.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
Memory management.
Swap Space and Other Memory Management Issues Operating Systems: Internals and Design Principles.
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.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 9 – Real Memory Organization and Management Outline 9.1 Introduction 9.2Memory Organization.
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.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Computer Architecture Chapter (8): Operating System Support
CS703 - Advanced Operating Systems By Mr. Farhan Zaidi.
Computer Organization
Chapter 2: The Linux System Part 4
Memory Management.
Chapter 2 Memory and process management
Understanding Operating Systems Seventh Edition
Chapter 8: Main Memory.
ITEC 202 Operating Systems
Chapter 9 – Real Memory Organization and Management
CSI 400/500 Operating Systems Spring 2009
Main Memory Management
O.S Lecture 13 Virtual Memory.
Page Replacement.
Evaluating System Performance
Multistep Processing of a User Program
Unit 6: Real Memory organization management
So far… Text RO …. printf() RW link printf Linking, loading
Main Memory Background Swapping Contiguous Allocation Paging
Operating Systems.
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
COMP755 Advanced Operating Systems
Operating Systems: Internals and Design Principles, 6/E
Chapter 8 & 9 Main Memory and Virtual Memory
Presentation transcript:

Computer Systems Week 14: Memory Management Amanda Oddie

2 Session Aims Understand how main memory (RAM) can be shared between programs running in time slices

3 Main Memory Programs can only execute efficiently if they are present in main memory during execution Only main memory is fast enough to feed the CPU with enough instructions and data to keep it usefully occupied. Thus main memory is a precious resource which must be managed carefully on a multiprogramming machine

4 Main Memory In addition to holding instructions RAM is also a workspace, a transient storage repository. Space must also be made available for: Operating System Code Operating System Data Video Storage Space etc

5 Imagine loading... Microsoft Windows Microsoft Internet Explorer An Application Microsoft Word And listening to music using media player whilst you do all that multi-tasking! It doesn’t stop there. You need memory for your hardware. For example you require main memory to display images on your monitor

6 Not enough memory Each time a PROCESS starts it REQUESTS an amount of RAM The amount of total RAM requested is usually more than the amount of Physical RAM available in Multiprogramming Operating Systems such as Windows and Linux

7 Hard disk, Main memory and CPU CPU 0  ? Hard disk Fetch and execute Memory Load program into main memory Start executing the program

8 Single Process System Early method Operating system loaded first Just one user program loaded into locations above the operating system Inefficient use of memory – small programs leave much unused memory space UNUSED User Process Operating System Memory 0

9 Fixed Memory Partition Memory divided into fixed partitions Several programs could run simultaneously Space still wasted inside each partition Process C Process B Process A Operating System 100k 300k 600k Memory address Partition 1 200k Partition 2 300k Partition 3 400k 1000k Memory 0

10 Sharing by swapping Program and data copied into memory at beginning of each time slice copied back to disc at end of time slice All main memory available to program But, high overhead of swapping time

11 Solution Paging

12 Sharing by paging Divide program and data into pages normally resident on the hard disk Each page is typically 4kB in size Only swap in the pages needed during time slice Memory divided into pageframes Each pageframe can hold one page

13 Loading pages Pages can be loaded in any order Use a page table for each program to keep track of where in memory its pages are located

14 Translating addresses Given an instruction like JMP means 314 locations from beginning of program This does not refer to a physical address in real memory but to a virtual address measured from the program start Assume each page 100 locations long JMP 314 means jump to page 3 offset 14 Where is the location in real memory ?

15 Virtual Memory The Operating System has a Memory Management Unit MMU that translates virtual addresses to physical addresses in RAM. This is known as Address Translation

16 Carrying out the translation JMP 314 Page number Real memory address: 2514 Page table

17 Page fault Interrupt generated when required page is not in main memory It causes: Required page to be fetched from disc into a spare pageframe If no pageframe is spare then an existing page must be freed up by copying its current contents back to the disk Page table updated Program continues

18 Thrashing Page faults are too frequent Most time spent swapping pages Caused by: Bad program design Too many programs attempting to run concurrently

19 Paging strategies Fetch strategy When to fetch a page Replacement strategy When to swap page out

20 Fetch strategies Demand fetch Anticipatory fetch

21 Replacement strategies Optimal page replacement Longest resident Least recently used Least frequently used

22 Page File The area of the hard disk that stores the RAM image is called a page file. It holds pages of RAM on the hard disk The Operating System moves data back and forth between the page file and RAM. Previous versions of Windows called this a swap file and had a.SWP extension.

23 Total Size of the Page File The size of the page file is based on how much RAM is installed in the computer. By default, Windows XP creates a page file which is 1.5 times the amount of installed RAM The page file is placed on the hard drive in the same folder as the Windows XP operating system

24 Question What is never paged out? The Kernel remains resident in RAM, This is never paged out.

25 Invalid Page Faults? The CPU trying to access an address out of range The CPU trying to access an address which is already occupied by a different process When the page that the CPU is trying to access does not exist in either RAM or VM

26 Invalid Page Faults Sometimes, through program or hardware error, the page is not there. The system then has an ‘Invalid Page Fault’ error. This will be a fatal error if detected in a program The Application is normally shut down by the Operating System

27 Improving Performance The page file is a reserved section of the hard drive where data may be written and retrieved as needed. Since the paging file and operating system files are by default located on the same drive, parallel access to both locations is impossible. One or the other has to wait, slowing down overall system performance. Moving the page file to another drive will improve performance.

28 Question How else could you improve performance? Installing more RAM

29 Memory Management in Windows Processes Memory Usage Virtual Memory Usage Performance Commit Charge Physical Memory Kernel Memory

30 Windows Task Manager Process Name Virtual Memory Usage Each Process has a Amount of Virtual Memory Limit of 4GB Physical Memory Usage

31 Commit Charge Physical Memory Kernel Memory

32 Question What is Fragmentation? The scattering of parts of a file throughout a disk, e.g. when the operating system breaks up the file and fits it into the spaces left vacant by previously deleted files.

33 Non-Contiguous Page Files Paging files are normally created when a drive is relatively empty finding a large contiguous block of space is not a problem. A page file is dynamic by default it can be expanded and contracted depending on the amount of extra virtual memory that's needed. If the initial block of drive space that was allocated at setup becomes surrounded by additional files that have been saved to the drive......a split page file can occur when the operating system expands it past the initial size.

34 Question How do you defragment files? Windows comes with a utility called Disk Defragmenter which will reorganise the files stored on disk

35 Question What creates the Page File? a) The CPU b) The RAM c) The Operating System d) It’s created by magic

36 Question What creates the Page File? a) The CPU b) The RAM c) The Operating System d) It’s created by magic Answer C: With help from the CPU

37 So What do we Know? Main memory (RAM) is a precious resource Every process and device requires RAM Virtual Memory through paging gives the impression that there is more RAM than physical RAM The Kernel is never Paged Out Paging is Managed by the Memory Management Unit (MMU) Page Faults are normal interrupts Invalid Page Faults are bad How to view Memory Allocation and Resources in Windows