CSE 4/521 Introduction to Operating Systems. Lecture 12 Main Memory I (Background, Swapping) Summer 2018

Similar documents
Main Memory (Part I)

Background. Contiguous Memory Allocation

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

CS420: Operating Systems

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Chapter 8: Memory- Management Strategies

Chapter 8: Memory Management. Operating System Concepts with Java 8 th Edition

Chapter 8: Main Memory. Operating System Concepts 9 th Edition

Chapter 8: Main Memory

CS370 Operating Systems

Chapter 8: Main Memory

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

Memory Management. CSCI 315 Operating Systems Design Department of Computer Science

Chapter 8: Memory-Management Strategies

Chapter 7: Main Memory. Operating System Concepts Essentials 8 th Edition

Chapter 8: Main Memory

Chapter 8: Main Memory

CHAPTER 8: MEMORY MANAGEMENT. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Performance of Various Levels of Storage. Movement between levels of storage hierarchy can be explicit or implicit

Chapter 8: Memory Management Strategies

Memory management. Last modified: Adaptation of Silberschatz, Galvin, Gagne slides for the textbook Applied Operating Systems Concepts

CS370 Operating Systems

CS307: Operating Systems

Chapter 8: Memory Management. Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging

Chapters 9 & 10: Memory Management and Virtual Memory

Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1

Chapter 9: Memory Management. Background

Part Three - Memory Management. Chapter 8: Memory-Management Strategies

8.1 Background. Part Four - Memory Management. Chapter 8: Memory-Management Management Strategies. Chapter 8: Memory Management

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 8: MEMORY

Memory Management. Contents: Memory Management. How to generate code? Background

Chapter 8: Memory Management

Chapter 8: Memory Management

Memory Management. Memory Management

Chapter 8 Memory Management

I.-C. Lin, Assistant Professor. Textbook: Operating System Principles 7ed CHAPTER 8: MEMORY

Roadmap. Tevfik Koşar. CSC Operating Systems Spring Lecture - XII Main Memory - II. Louisiana State University

Virtual Memory Silberschatz: 9. Operating Systems. Autumn CS4023

Module 8: Memory Management

Lecture 8 Memory Management Strategies (chapter 8)

Main Memory. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & APPS 1

Outlook. Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium

Unit-03 Deadlock and Memory Management Unit-03/Lecture-01

Logical versus Physical Address Space

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

6 - Main Memory EECE 315 (101) ECE UBC 2013 W2

Module 8: Memory Management

Module 9: Memory Management. Background. Binding of Instructions and Data to Memory

Memory Management Cache Base and Limit Registers base limit Binding of Instructions and Data to Memory Compile time absolute code Load time

Chapter 8: Memory- Manage g me m nt n S tra r t a e t gie i s

12: Memory Management

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation

Operating Systems. Memory Management. Lecture 9 Michael O Boyle

Principles of Operating Systems

SHANDONG UNIVERSITY 1

Memory Management. Reading: Silberschatz chapter 9 Reading: Stallings. chapter 7 EEL 358

Course: Operating Systems Instructor: M Umair. M Umair

CSE 4/521 Introduction to Operating Systems. Lecture 15 Virtual Memory I (Background, Demand Paging) Summer 2018

Chapter 8: Memory- Management Strategies Dr. Varin Chouvatut

Administrivia. Deadlock Prevention Techniques. Handling Deadlock. Deadlock Avoidance

Memory Management 9th Week

Main Memory Yi Shi Fall 2017 Xi an Jiaotong University

Memory Management and Protection

Chapter 8: Main Memory. Operating System Concepts 8th Edition

CSE 4/521 Introduction to Operating Systems. Lecture 24 I/O Systems (Overview, Application I/O Interface, Kernel I/O Subsystem) Summer 2018

Main Memory. CISC3595, Spring 2015 X. Zhang Fordham University

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

File Systems. OS Overview I/O. Swap. Management. Operations CPU. Hard Drive. Management. Memory. Hard Drive. CSI3131 Topics. Structure.

CSE 4/521 Introduction to Operating Systems. Lecture 14 Main Memory III (Paging, Structure of Page Table) Summer 2018

Memory management: outline

Memory management: outline

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18

Module 3. DEADLOCK AND STARVATION

Basic Memory Management

Topics: Memory Management (SGG, Chapter 08) 8.1, 8.2, 8.3, 8.5, 8.6 CS 3733 Operating Systems

P r a t t hr h ee e : e M e M m e o m r o y y M a M n a a n g a e g m e e m n e t 8.1/72

3. Memory Management

Chapter 8 Main Memory

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Lesson 5: Deadlocks Memory management (Part 1)

Memory Management. Goals of Memory Management. Mechanism. Policies

CSE 421/521 - Operating Systems Fall Lecture - XII Main Memory Management. Tevfik Koşar. University at Buffalo. October 18 th, 2012.

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

CSE 4/521 Introduction to Operating Systems

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - XI Deadlocks - II. University at Buffalo. Deadlocks. October 6 th, 2011

CS 143A - Principles of Operating Systems

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

Last class: Today: Deadlocks. Memory Management

UNIT-III VIRTUAL MEMORY

9.1 Background. In Chapter 6, we showed how the CPU can be shared by a set of processes. As a result of

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management


CS399 New Beginnings. Jonathan Walpole

Memory Management. Frédéric Haziza Spring Department of Computer Systems Uppsala University

More on Synchronization and Deadlock

Operating Systems (2INC0) 2017/18

Transcription:

CSE 4/521 Introduction to Operating Systems Lecture 12 Main Memory I (Background, Swapping) Summer 2018

Overview Objective: 1. To provide a detailed description of various ways of organizing memory hardware. Background Swapping 2

Recap Deadlock System Model Representation of resources and processes in a system. Deadlock Characterization Mutual exclusion, hold-and-wait, no preemption, circular wait. No cycle no deadlock, A cycle possibility of deadlock. Methods for Handling Deadlocks Pretend deadlock never happened, deadlock prevention and avoidance. Deadlock Prevention Break all four conditions of deadlocks. 3

Questions 1. What are the 4 conditions in a system for a deadlock to occur? (Easy) 2. Is there a deadlock here? Why? (Medium) 3. How would you prevent the 4 conditions of deadlocks from happening? (Open-ended) 4

Overview Background Swapping 5

Overview Background Swapping 6

Background 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 CPU can access directly Register access in one CPU clock (or less) Main memory access can take many cycles, causing a stall Cache sits between main memory and CPU registers Protection of memory required to ensure correct operation 7

Background : Multistep Processing of User Program 8

Background: Logical vs. Physical Address Space The concept of a logical address space that is bound to a separate physical address space is central to 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 compiletime and load-time address-binding schemes; but different in execution-time address-binding scheme Logical address space is the set of all logical addresses generated by a program Physical address space is the set of all physical addresses generated by a program 9

Background : Base and Limit Registers A pair of base and limit registers define the logical address space 10

Background : Hardware Address Protection CPU must check every memory access generated in user mode to be sure it is between base and limit for that user 11

Background : Address Binding Programs on disk, ready to be brought into memory to execute Addresses represented in different ways at different stages of a program s life Source code addresses usually symbolic Compiled code addresses bind to relocatable addresses i.e. 14 bytes from beginning of this module Linker or loader will bind relocatable addresses to absolute addresses i.e. 74014 Each binding maps one address space to another 12

Background : Binding of Instructions and Data to Memory Address binding of instructions and data to memory addresses can happen at three different stages Compile time: If memory location known a priori, absolute code can be generated Load time: Must generate relocatable code if memory location is not known at compile time Execution time: Binding delayed until run time if the process can be moved during its execution from one memory segment to another Need hardware support for address maps (e.g., base and limit registers) 13

Background: Memory-Management Unit (MMU) Hardware device that at run time maps virtual to physical address The value in the relocation register is added to every address generated by a user process at the time it is sent to memory Base register now called relocation register The user program deals with logical addresses; it never sees the real physical addresses Execution-time binding occurs only when reference is made to location in memory Logical address bound to physical addresses 14

Background: Dynamic relocation using a relocation register Routine is not loaded until it is called Better memory-space utilization; unused routine is never loaded All routines kept on disk in relocatable load format Useful when large amounts of code are needed to handle infrequently occurring cases 15

Background: Dynamic Linking Static linking system libraries and program code combined by the loader into the binary program image Dynamic linking linking postponed until execution time Small piece of code, stub, used to locate the appropriate memory-resident library routine Stub replaces itself with the address of the routine, and executes the routine Operating system checks if routine is in processes memory address If not in address space, add to address space Dynamic linking is particularly useful for libraries 16

Overview Background Swapping 17

Swapping A process can be swapped temporarily out of memory to a backing store, and then brought back into memory for continued execution Backing store fast disk large enough to accommodate copies of all memory images for all users; must provide direct access to these memory images Major part of swap time is transfer time; total transfer time is directly proportional to the amount of memory swapped System maintains a ready queue of ready-to-run processes which have memory images on disk 18

Swapping : Schematic View of Swapping 19

Swapping Does the swapped out process need to swap back in to same physical addresses? Depends on address binding method Plus consider pending I/O to/from process memory space Modified versions of swapping are found on many systems (i.e., UNIX, Linux, and Windows) Swapping normally disabled Started if more than threshold amount of memory allocated Disabled again once memory demand reduced below threshold 20

Swapping : Context Switch Time including Swapping If next processes to be put on CPU is not in memory, need to swap out a process and swap in target process Context switch time can then be very high 100MB process swapping to hard disk with transfer rate of 50MB/sec Swap out time of 2000ms Plus swap in of same sized process Total context switch swapping component time of 4000ms (4 seconds) 21

Swapping : Context Switch Time and Swapping Other constraints on swapping Pending I/O can t swap out as I/O would occur to wrong process Or always transfer I/O to kernel space, then to I/O device Known as double buffering, adds overhead Standard swapping not used in modern operating systems But modified version common Swap only when free memory extremely low 22

Swapping : Swapping on Mobile Systems Not typically supported Flash memory based Small amount of space Limited number of write cycles Instead use other methods to free memory if low ios asks apps to voluntarily relinquish allocated memory Failure to free can result in termination Android terminates apps if low free memory, but first writes application state to flash for fast restart 23

Credits for slides Silberschatz, Galvin and Gagne 24