From Monoprogramming to multiprogramming with swapping

Slides:



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

Part IV: Memory Management
Memory management In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. Memory management is achieved.
Memory Management Today Basic memory management Swapping Kernel memory allocation Next Time Virtual memory.
1 CSE 380 Computer Operating Systems Instructor: Insup Lee University of Pennsylvania, Fall 2002 Lecture Note: Memory Management.
Memory Management Chapter 4. Memory hierarchy Programmers want a lot of fast, non- volatile memory But, here is what we have:
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management - 2 CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent.
Multiprocessing Memory Management
Chapter 3.1 : Memory Management
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent University.
Memory Management (continued) CS-3013 C-term Memory Management CS-3013 Operating Systems C-term 2008 (Slides include materials from Operating System.
Memory ManagementCS-3013 A-term Memory Management CS-3013, Operating Systems A-term 2009 (Slides include materials from Modern Operating Systems,
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 ManagementCS-502 Fall Memory Management CS-502 Operating Systems Fall 2006 (Slides include materials from Operating System Concepts, 7 th.
CS 333 Introduction to Operating Systems Class 9 - Memory Management
Computer Organization and Architecture
Memory Management Five Requirements for Memory Management to satisfy: –Relocation Users generally don’t know where they will be placed in main memory May.
Memory ManagementCS-3013 C-term Memory Management CS-3013 Operating Systems C-term 2008 (Slides include materials from Operating System Concepts,
Avishai Wool lecture Introduction to Systems Programming Lecture 6 Memory Management.
1 Chapter 3.1 : Memory Management Storage hierarchy Storage hierarchy Important memory terms Important memory terms Earlier memory allocation schemes Earlier.
Memory Management From Chapter 4, Modern Operating Systems, Andrew S. Tanenbaum.
Memory Management By: Omar A. Cruz Salgado ICOM 5007 Sec. 121.
Dynamic Partition Allocation Allocate memory depending on requirements Partitions adjust depending on memory size Requires relocatable code –Works best.
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”
1 Memory Management Chapter Basic memory management 4.2 Swapping (εναλλαγή) 4.3 Virtual memory (εικονική/ιδεατή μνήμη) 4.4 Page replacement algorithms.
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.
1 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms.
Chapter 10 Memory Management Introduction Process must be loaded into memory before being executed. Input queue – collection of processes on the.
1 Memory Management Basics. 2 Program P Basic Memory Management Concepts Address spaces Physical address space — The address space supported by the hardware.
Operating Systems COMP 4850/CISG 5550 Basic Memory Management Swapping Dr. James Money.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Memory Management Overview.
1 ADVANCED OPERATING SYSTEMS Lecture 8 (Week 10) Resource Management – II (Memory Management) by: Syed Imtiaz Ali.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Mono an multiprogramming.
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 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.
CHAPTER 3-1, 3-2 MEMORY MANAGEMENT. MEMORY HIERARCHY Small amount of expensive, fast, volatile cache Larger amount of still fast, but slower, volatile.
Memory Management Chapter 5 Advanced Operating System.
1 Memory Management Adapted From Modern Operating Systems, Andrew S. Tanenbaum.
Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”
Memory Management One of the most important OS jobs.
Chapter 2 Memory and process management
Chapter 8: Main Memory.
Memory Allocation The main memory must accommodate both:
CSC 322 Operating Systems Concepts Lecture - 12: by
Partitioned Memory Allocation
Memory Management © 2004, D. J. Foreman.
Chapter 9 – Real Memory Organization and Management
PA1 is out Best by Feb , 10:00 pm Enjoy early
Main Memory Management
Chapter 8: Main Memory.
Lecture 26: Memory Management - Swapping
Lecture 28: Virtual Memory-Address Translation
The Operating System Memory Manager
Multistep Processing of a User Program
So far… Text RO …. printf() RW link printf Linking, loading
Chapter3 Memory Management Techniques
Main Memory Background Swapping Contiguous Allocation Paging
CS399 New Beginnings Jonathan Walpole.
Introduction to Memory Management
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.
Memory Management Overview
Lecture 3: Main Memory.
Memory Management (1).
COMP755 Advanced Operating Systems
Lecture 26: Memory Management - Swapping
Page Main Memory.
Presentation transcript:

From Monoprogramming to multiprogramming with swapping Memory Management From Monoprogramming to multiprogramming with swapping

Memory Hierarchy Small amount of expensive, fast, volatile cache Larger amount of still fast, but slower, volatile ram Vast amount of inexpensive, not volatile, but slow secondary storage

Memory Manager Keeps track of which parts of memory are in use Allocate memory to processes when needed Deallocate memory when processes complete

Monoprogramming Memory is divided between o/s, process, device drivers o/s signals user when process is finished. Waits for command to load another Two drawbacks: A single process can run. Time wasted waiting on i/o Processes (include o/s) are exposed to malicious or badly written code

monoprogramming a) Pre-1960 mainframes b) Embedded systems c) Early PCs

Multiprogramming Run process A when process B is waiting Degree of multiprogramming Processes spend up to 80% of time waiting for i/o Suppose process spends fraction, t, waiting for i/o If N processes, probability that all are waiting is tN Then CPU use is 1 - tN N is called degree of multiprogramming

Example Suppose we want 95% CPU use Suppose we want 90% CPU use ln 5 – ln 100 = n * (ln 8 – ln 10) N ~ 13.6

Multiprograming Requires that we rethink Memory 16 kb program runs alone. Finishes os loads new program. Finishes Now suppose os tries to multiprogram. Instead of evicting old program, adds new one above it. jmp 28 causes an error Problem: both programs reference static, physical addresses -

First Things First Multiprogramming requires solution to two problems protection: process 1 may not overwrite process 2 relocation: remap process memory to different parts of physical memory Address Space The set of addresses available to a process Each process has its own address space Key idea: address 28 in process 1 is not the same physical address as address 28 in process 2

Solution to Basic multiprogramming Problem Base and Limit Registers Simple solution to relocation problem. Base register holds the beginning address of the process Limit register holds length of the process jmp 28 jumps base register + 28

Problem Degree of multiprogramming limited by the amount of memory Windows/OS X/Linux 50 – 100 processes may be started up at boot time Two General Solutions Swapping Load each process Run it for a little while Save it to disk Virtual Memory Load only parts of processes

Swapping (Solution 1 to multiprogramming Problem) Memory allocation changes as processes come into memory and leave it. The shaded regions are unused memory

Swapping Issues Problem 1 Swapping creates holes in memory (external fragmentation) Can be relieved through (very expensive) memory compaction Problem 2 Have assumed that programs have a fixed size But many programming languages allow for dynamically allocated memory If free store is adjacent to a process, it can be claimed If not, the growing process will have to be moved to a hole large enough to accommodate it or swapped out and suspended.

Size Issue allocate extra space at load time Distinguish between dynamically allocated heap memory and local stack memory

Keeping Track of Growing/Shrinking Memory with bit maps and Linked Lists A part of memory with five processes and three holes. The tickmarks show the memory allocation units. The shaded regions (0 in the bitmap) are free. The corresponding bitmap Linked list memory management Problems with bit maps Large allocation unit results in holes in the last unit of the process Small allocation unit requires large bitmap Bitmap must be searched at each load to look for the right size space

Is X adjacent to another process? Process Terminates Is X adjacent to another process?

Finding a whole large enough for the process First fit Scan linked list looking for the first whole that is big enough Results in fragmentation Next fit Start search where last search ended to avoid small hole clustering Best fit Scan all of memory looking for the best fit Sounds good, but results in many tiny and useless holes Worst fit OK. Look for the largest available hole. Also produces fragmentation There are other possibilities, including a doubly linked list to make merging easier. Fragmentation is a problem with all possibilites