CSC 322 Operating Systems Concepts Lecture - 12: by

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

CS 311 – Lecture 21 Outline Memory management in UNIX
1 CSE 380 Computer Operating Systems Instructor: Insup Lee University of Pennsylvania, Fall 2002 Lecture Note: Memory Management.
Modified from Silberschatz, Galvin and Gagne Lecture 16 Chapter 8: Main Memory.
CS 104 Introduction to Computer Science and Graphics Problems
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.
Avishai Wool lecture Introduction to Systems Programming Lecture 6 Memory Management.
Silberschatz, Galvin and Gagne  Operating System Concepts Multistep Processing of a User Program User programs go through several steps before.
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Memory Management By: Omar A. Cruz Salgado ICOM 5007 Sec. 121.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 8: Main Memory.
Swapping and Contiguous Memory Allocation. Multistep Processing of a User Program User programs go through several steps before being run. Program components.
Lecture 13 L.Mohammad R.Alkafagee1.  The concept of a logical address space that is bound to a separate physical address space is central to proper memory.
8.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 8: Memory-Management Strategies Objectives To provide a detailed description.
Chapter 4 Storage Management (Memory Management).
Chapter 4 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 1 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation.
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.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation.
Operating Systems COMP 4850/CISG 5550 Basic Memory Management Swapping Dr. James Money.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
1 ADVANCED OPERATING SYSTEMS Lecture 8 (Week 10) Resource Management – II (Memory Management) by: Syed Imtiaz Ali.
CS6502 Operating Systems - Dr. J. Garrido Memory Management – Part 1 Class Will Start Momentarily… Lecture 8b CS6502 Operating Systems Dr. Jose M. Garrido.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 31 Memory Management.
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.
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.
Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
Main Memory CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Memory Management One of the most important OS jobs.
Module 9: Memory Management
Chapter 9: Memory Management
Memory Management.
From Monoprogramming to multiprogramming with swapping
Chapter 8: Main Memory.
Chapter 8: Memory Management
Chapter 8: Main Memory.
CSC 322 Operating Systems Concepts Lecture - 16: by
Main Memory Management
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
Storage Management Chapter 9: Memory Management
Operating System Concepts
MEMORY MANAGEMENT & their issues
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
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.
Multistep Processing of a User Program
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
So far… Text RO …. printf() RW link printf Linking, loading
Memory Management-I 1.
Main Memory Background Swapping Contiguous Allocation Paging
CS399 New Beginnings Jonathan Walpole.
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.
Chapter 8: Memory Management strategies
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 MEMORY MANAGEMENT BY DR.V.R.ELANGOVAN.
CSE 542: Operating Systems
Page Main Memory.
Presentation transcript:

CSC 322 Operating Systems Concepts Lecture - 12: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. (Chapter-3) Ahmed Mumtaz Mustehsan, CIIT, Islamabad 1

Chapter 3 Memory Management Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Memory Management Basics Don’t have infinite RAM Do have a memory hierarchy Cache (Few MB very fast, expensive, volatile ) Main ( Few GB, medium speed, medium priced, volatile) Disk ( Few TB, slow, cheap, nonvolatile ) Memory manager has the job of using this hierarchy to create an abstraction (illusion) of easily accessible memory Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad One program at a time in memory OS loads a program from disk to memory and execute. Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad One program at a time The simplest memory abstraction; no abstraction Early mainframe computers (before 1960), early minicomputers (before 1970), and early personal computers (before 1980) had no memory abstraction Can only have one program in memory at a time. Bug in user program can trash the OS (a and c) Second on some embedded systems (b) Third on MS-DOS (early PCs) part in ROM called BIOS (Basic Input Output System) Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Running Multiple Programs w.o Memory Abstraction Save the entire contents of memory to a disk file, then bring in and run the next program Could swap new program into memory from disk and send old one out to disk Only one program at a time in the memory Not concurrent so no conflicts Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Schematic View of Swapping Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad IBM static relocation idea Special hardware, it is possible to run multiple programs concurrently, even without swapping IBM 360 -divide memory into 2 KB blocks, and associate a 4 bit protection key with chunk. Keep keys in registers. A machine with a 1-MB memory needed 512 of 4-bit registers for a total of 256 bytes of key storage Put key into PSW for program Hardware prevents program from accessing block with another protection key Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Problem with relocation Fig 3-2: Illustration of the relocation problem. (a) A 16-KB program. (b)Another 16-KB program. (c) The two programs loaded consecutively into memory starting at address 0 In (c) JMP 28 in program (b) trashes ADD instruction in location 28 Program crashes Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Static relocation Problem is that both programs reference absolute physical memory. Static relocation- load first instruction of program at address x, and add x to every subsequent address during loading This is too slow and Not all addresses can be modified MOV Register, 28 can’t be modified as 28 is data not the address. Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Address Space Create abstract memory space for program to exist in main memory. Each program has its own set of addresses The addresses are different for each program Call it the address space of the program Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Logical vs. Physical Address Space The concept of a logical address space that is bound to a separate physical address space is the main focus for a proper memory management. Logical address – Generated by the CPU; also referred to as virtual address Physical address – address seen by the memory unit Logical and physical addresses are the same in compile time and load time address binding schemes; logical (virtual) and physical addresses differ in execution-time address-binding scheme. Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Base and Limit Registers A form of dynamic relocation Base contains beginning address of program Limit contains length of program Program references memory, adds base address to address generated by process. Checks to see if address is not within the limit. it, generates fault Disadvantage-addition and comparison have to be done on every instruction Used in the CDC 6600 and the Intel 8088 Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Memory-Management Unit (MMU) Hardware device that maps virtual to physical address In MMU scheme, the value in the relocation register is added to every address generated by a user process at the time it is sent to memory. The user program deals with logical addresses; it never sees the real physical addresses. Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Dynamic Relocation Using a Relocation Register Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Dynamic Loading Routine is not loaded until it is called Better memory space utilization; unused routine is never loaded Useful when large amounts of code are needed to handle infrequently occurring cases No special support from the operating system is required implemented through program design Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

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 Relocation registers used to protect user processes from each other, and from changing operating-system code and data Base register contains value of smallest physical address Limit register contains range of logical addresses each logical address must be less than the limit register MMU maps logical address dynamically Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Hardware Support for Relocation and Limit Registers Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Base and Limit Registers Add 16384 to JMP 28. Hardware adds 16384 to 28 resulting in JMP 16412 Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad How to run more programs then fit in main memory at once Can’t keep all processes in main memory Too many (hundreds) Too big (e.g. 200 MB program) Two approaches Swap-bring program in and run it for awhile Virtual memory-allow program to run even if only part of it is in main memory Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Swapping, a picture Can compact holes by copying programs into holes This takes too much time Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Programs grow as they execute Stack (return addresses and local variables) Data segment (heap for variables which are dynamically allocated and released) Good idea to allocate extra memory for both When program goes back to disk, don’t bring holes along with it!!! Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad 2 ways to allocate space for growth Just add extra space Stack grows downwards, data grows upwards Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Managing Free Memory Two techniques to keep track of free memory Bitmaps Linked lists Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Bitmaps-the picture (a) Picture of memory (b) Each bit in bitmap corresponds to a unit of storage (e.g. bytes) in memory (c) Linked list P: process H: hole Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Bitmaps The good-compact way to keep tract of memory The bad-need to search memory for k consecutive zeros to bring in a file k units long Units can be bits or bytes or……. Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Linked Lists-the picture Four neighbor combinations for the terminating process, X. Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad Linked Lists Might want to use doubly linked lists to merge holes more easily Algorithms to fill in the holes in memory First fit Next fit Best fit Worst fit Quick fit Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad The fits First fit-fast Next fit-starts search wherever it is Slightly worse Best fit-smallest hole that fits Slower, results in a bunch of small holes (i.e. worse algorithm) Worst fit-largest hole that fits Not good (simulation results) Quick fit- keep list of common sizes Quick, but can’t find neighbors to merge with Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Ahmed Mumtaz Mustehsan, CIIT, Islamabad The fits Conclusion: the fits couldn’t out-smart the un-knowable distribution of hole sizes Lecture-12 Ahmed Mumtaz Mustehsan, CIIT, Islamabad