CS703 - Advanced Operating Systems By Mr. Farhan Zaidi.

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

Fabián E. Bustamante, Spring 2007
CS 153 Design of Operating Systems Spring 2015
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.
CS 333 Introduction to Operating Systems Class 9 - Memory Management
MEMORY MANAGEMENT By KUNAL KADAKIA RISHIT SHAH. Memory Memory is a large array of words or bytes, each with its own address. It is a repository of quickly.
Silberschatz, Galvin and Gagne  Operating System Concepts Multistep Processing of a User Program User programs go through several steps before.
CS364 CH08 Operating System Support TECH Computer Science Operating System Overview Scheduling Memory Management Pentium II and PowerPC Memory Management.
Memory Management CSE451 Andrew Whitaker. Big Picture Up till now, we’ve focused on how multiple programs share the CPU Now: how do multiple programs.
CSE451 Operating Systems Winter 2012 Memory Management Mark Zbikowski Gary Kimura.
Swapping and Contiguous Memory Allocation. Multistep Processing of a User Program User programs go through several steps before being run. Program components.
Operating Systems ECE344 Ding Yuan Memory Management Lecture 7: Memory Management.
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.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
CENG334 Introduction to Operating Systems Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY URL:
CSE 451: Operating Systems Fall 2010 Module 10 Memory Management Adapted from slides by Chia-Chi Teng.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
CSE 451: Operating Systems Winter 2015 Module 11 Memory Management Mark Zbikowski Allen Center 476 © 2013 Gribble, Lazowska, Levy,
CS161 – Design and Architecture of Computer
Memory Management.
Chapter 8: Main Memory.
CS161 – Design and Architecture of Computer
CSE 120 Principles of Operating
CSE 451: Operating Systems Winter 2007 Module 10 Memory Management
CSC 322 Operating Systems Concepts Lecture - 12: by
CS703 - Advanced Operating Systems
CSE451 Operating Systems Winter 2011
CSE 451: Operating Systems Winter 2010 Module 10 Memory Management
CSE 451: Operating Systems Winter 2014 Module 11 Memory Management
Chapter 9 – Real Memory Organization and Management
Main Memory Management
Chapter 8: Main Memory.
Virtual Memory Partially Adapted from:
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
Memory Management 11/17/2018 A. Berrached:CS4315:UHD.
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
Operating System Main Memory
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.
CSE 451: Operating Systems Autumn 2005 Memory Management
CSE 451: Operating Systems Autumn 2004 Memory Management
Contents Memory types & memory hierarchy Virtual memory (VM)
CSE 451: Operating Systems Winter 2007 Module 10 Memory Management
Chapter 8: Memory Management strategies
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
CSE 451: Operating Systems Autumn 2009 Module 10 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Memory Management CSE451 Andrew Whitaker.
CSE 451: Operating Systems Winter 2004 Module 10 Memory Management
CS703 - Advanced Operating Systems
CSE451 Operating Systems Winter 2009
COMP755 Advanced Operating Systems
EECE.4810/EECE.5730 Operating Systems
CSE 451: Operating Systems Autumn 2010 Module 10 Memory Management
CSE 542: Operating Systems
Page Main Memory.
Presentation transcript:

CS703 - Advanced Operating Systems By Mr. Farhan Zaidi

Lecture No. 23

Overview of today’s lecture Goals of OS memory management Questions regarding memory management Multiprogramming Virtual addresses Fixed partitioning Variable partitioning Fragmentation

Goals of OS memory management Allocate scarce memory resources among competing processes, maximizing memory utilization and system throughput Provide isolation between processes

Tools of memory management Base and limit registers Swapping Paging (and page tables and TLBs) Segmentation (and segment tables) Page fault handling => Virtual memory The policies that govern the use of these mechanisms

Our main questions regarding Memory Management How is protection enforced? How are processes relocated? How is memory partitioned?

Today’s desktop and server systems The basic abstraction that the OS provides for memory management is virtual memory (VM)  VM enables programs to execute without requiring their entire address space to be resident in physical memory program can also execute on machines with less RAM than it “needs”  many programs don’t need all of their code or data at once (or ever) e.g., branches they never take, or data they never read/write no need to allocate memory for it, OS should adjust amount allocated based on run-time behavior  virtual memory isolates processes from each other one process cannot name addresses visible to others; each process has its own isolated address space

Virtual memory requires hardware and OS support  MMU’s, TLB’s, page tables, page fault handling, … Typically accompanied by swapping, and at least limited segmentation

Multiprogramming: Linker-loader Can multiple programs share physical memory, without hardware translation? Yes: when copy program into memory, change its addresses (loads, stores, jumps) to use the addresses of where program lands in memory. This relocation is performed by a linker-loader.

UNIX ld works this way: compiler generates each.o file with code that starts at location 0. How do you create an executable from this? Scan through each.o, changing addresses to point to where each module goes in larger program (requires help from compiler to say where all the re-locatable addresses are stored). With linker-loader, no protection: one program's bugs can cause other programs to crash.

Swapping  save a program’s entire state (including its memory image) to disk  allows another program to be run  first program can be swapped back in and re-started right where it was The first timesharing system, MIT’s “Compatible Time Sharing System” (CTSS), was a uni-programmed swapping system  only one memory-resident user  upon request completion or quantum expiration, a swap took place  Amazing even to think about today how bad the performance would be … but it worked!

multiple processes/jobs in memory at once to overlap I/O and computation  memory management requirements: protection: restrict which addresses processes can use, so they can’t stomp on each other fast translation: memory lookups must be fast, in spite of the protection scheme fast context switching: when switching between jobs, updating memory hardware (protection and translation) must be quick

Virtual addresses for multiprogramming To make it easier to manage memory of multiple processes, make processes use virtual addresses (which is not what we mean by “virtual memory” today!)  virtual addresses are independent of location in physical memory (RAM) where referenced data lives OS determines location in physical memory  instructions issued by CPU reference virtual addresses e.g., pointers, arguments to load/store instructions, PC …  virtual addresses are translated by hardware into physical addresses (with some setup from OS)

The set of virtual addresses a process can reference is its address space  many different possible mechanisms for translating virtual addresses to physical addresses we’ll take a historical walk through them, ending up with our current techniques Note: We are not yet talking about paging, or virtual memory – only that the program issues addresses in a virtual address space, and these must be “adjusted” to reference memory (the physical address space)  for now, think of the program as having a contiguous virtual address space that starts at 0, and a contiguous physical address space that starts somewhere else

Memory Hierarchy Two principles: 1. The smaller amount of memory needed, the faster that memory can be accessed. 2. The larger amount of memory, the cheaper per byte. Thus, put frequently accessed stuff in small, fast, expensive memory; use large, slow, cheap memory for everything else. Works because programs aren't random. Exploit locality: that computers usually behave in future like they have in the past. Temporal locality: will reference same locations as accessed in the recent past Spatial locality: will reference locations near those accessed in the recent past

CPU regs CacheCache Memory disk size: speed: $/Mbyte: line size: 32 B 1 ns 8 B RegisterCacheMemoryDisk Memory 32 KB-4MB 2 ns $125/MB 32 B 1024 MB 30 ns $0.20/MB 4 KB 100 GB 8 ms $0.001/MB larger, slower, cheaper 8 B32 B4 KB cachevirtual memory Levels in Memory Hierarchy

Old technique #1: Fixed partitions Physical memory is broken up into fixed partitions  partitions may have different sizes, but partitioning never changes  hardware requirement: base register, limit register physical address = virtual address + base register base register loaded by OS when it switches to a process  how do we provide protection? if (physical address > base + limit) then… ? Advantages  Simple Problems  internal fragmentation: the available partition is larger than what was requested  external fragmentation: two small partitions left, but one big job – what sizes should the partitions be??

Mechanics of fixed partitions partition 0 partition 1 partition 2 partition 3 0 2K 6K 8K 12K physical memory offset + virtual address P2’s base: 6K base register 2K <? no raise protection fault limit register yes

Old technique #2: Variable partitions Obvious next step: physical memory is broken up into partitions dynamically – partitions are tailored to programs  hardware requirements: base register, limit register  physical address = virtual address + base register  how do we provide protection? if (physical address > base + limit) then… ? Advantages  no internal fragmentation simply allocate partition size to be just big enough for process (assuming we know what that is!) Problems  external fragmentation as we load and unload jobs, holes are left scattered throughout physical memory slightly different than the external fragmentation for fixed partition systems

Mechanics of variable partitions partition 0 partition 1 partition 2 partition 3 partition 4 physical memory offset + virtual address P3’s base base register P3’s size limit register <? raise protection fault no yes

Dealing with fragmentation partition 0 partition 1 partition 2 partition 3 partition 4 Swap a program out Re-load it, adjacent to another Adjust its base register partition 0 partition 1 partition 2 partition 3 partition 4