Memory Management, Early Systems

Similar documents
Chapter 7 Memory Management

Memory management basics (1) Requirements (1) Objectives. Operating Systems Part of E1.9 - Principles of Computers and Software Engineering

Memory Management Outline. Background Swapping Contiguous Memory Allocation Paging Segmentation Segmented Paging

OPERATING SYSTEM - MEMORY MANAGEMENT

Chapter 7 Memory Management

Chapter 12. Paging an Virtual Memory Systems

Memory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation

System Software Prof. Dr. H. Mössenböck

Memory unit sees only the addresses, and not how they are generated (instruction counter, indexing, direct)

OPERATING SYSTEMS MEMORY MANAGEMENT

& Data Processing 2. Exercise 3: Memory Management. Dipl.-Ing. Bogdan Marin. Universität Duisburg-Essen

Operating Systems, 6 th ed. Test Bank Chapter 7

The Deadlock Problem. Deadlocks. Deadlocks. Bridge Crossing Example

OPERATING SYSTEM - VIRTUAL MEMORY

Lecture 10: Dynamic Memory Allocation 1: Into the jaws of malloc()

OS OBJECTIVE QUESTIONS

Operating Systems. Virtual Memory

Chapter 14 MS-DOS Operating System

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

Memory Management 1. Memory Management. Multitasking without memory management is like having a party in a closet.

I/O Management. General Computer Architecture. Goals for I/O. Levels of I/O. Naming. I/O Management. COMP755 Advanced Operating Systems 1

Chapter 12 File Management. Roadmap

Chapter 12 File Management

Dynamics NAV/SQL Server Configuration Recommendations

DMS Performance Tuning Guide for SQL Server

CS5460: Operating Systems

Garbage Collection in the Java HotSpot Virtual Machine

File System Management

Operating System Tutorial

Convenience: An OS makes a computer more convenient to use. Efficiency: An OS allows the computer system resources to be used in an efficient manner.

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

Hardware Task Scheduling and Placement in Operating Systems for Dynamically Reconfigurable SoC

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

Contributions to Gang Scheduling

File-System Implementation

Technical Properties. Mobile Operating Systems. Overview Concepts of Mobile. Functions Processes. Lecture 11. Memory Management.

Two Parts. Filesystem Interface. Filesystem design. Interface the user sees. Implementing the interface

Filing Systems. Filing Systems

Java's garbage-collected heap

Segmentation and Fragmentation

Operating Systems CSE 410, Spring File Management. Stephen Wagner Michigan State University

2) Write in detail the issues in the design of code generator.

Virtual vs Physical Addresses

Azul Pauseless Garbage Collection

COURSE OUTLINE Survey of Operating Systems

Trace-Based and Sample-Based Profiling in Rational Application Developer

Chapter 3 Operating-System Structures

Chapter 11 I/O Management and Disk Scheduling

Chapter 2 Assemblers

CHAPTER 17: File Management

CS0206 OPERATING SYSTEMS Prerequisite CS0201, CS0203

Web Caching With Dynamic Content Abstract When caching is a good idea

Chapter 2: OS Overview

Industrial Flash Storage Trends in Software and Security

Routing Protocols (RIP, OSPF, BGP)

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Understanding Java Garbage Collection

Keil C51 Cross Compiler

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

WHITE PAPER Optimizing Virtual Platform Disk Performance

Multiprogramming. IT 3123 Hardware and Software Concepts. Program Dispatching. Multiprogramming. Program Dispatching. Program Dispatching

Solution: start more than one instruction in the same clock cycle CPI < 1 (or IPC > 1, Instructions per Cycle) Two approaches:

Garbage Collection in NonStop Server for Java

8085 INSTRUCTION SET

Microprocessor & Assembly Language

A Comparative Performance Analysis of Load Balancing Algorithms in Distributed System using Qualitative Parameters

Networking Virtualization Using FPGAs

Unit Storage Structures 1. Storage Structures. Unit 4.3

The Real-Time Operating System ucos-ii

Storage in Database Systems. CMPSCI 445 Fall 2010

Chapter 13 File and Database Systems

Chapter 13 File and Database Systems

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C


Lesson Objectives. To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization

Scheduling for QoS Management

Performance Monitoring User s Manual

Practical issues in DIY RAID Recovery

LogiCORE IP AXI Performance Monitor v2.00.a

Disk Space Management Methods

PROBLEMS #20,R0,R1 #$3A,R2,R4

Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 412, University of Maryland. Guest lecturer: David Hovemeyer.

Storage and File Structure

The International Journal Of Science & Technoledge (ISSN X)

6. Storage and File Structures

Introduction to I/O and Disk Management

File System & Device Drive. Overview of Mass Storage Structure. Moving head Disk Mechanism. HDD Pictures 11/13/2014. CS341: Operating System

Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis

In-memory Tables Technology overview and solutions

Quiz 4 Solutions EECS 211: FUNDAMENTALS OF COMPUTER PROGRAMMING II. 1 Q u i z 4 S o l u t i o n s

Secondary Storage. Any modern computer system will incorporate (at least) two levels of storage: magnetic disk/optical devices/tape systems

THROUGHPUTER. Parallel Program Development and Execution Platform as a Service

Road Map. Scheduling. Types of Scheduling. Scheduling. CPU Scheduling. Job Scheduling. Dickinson College Computer Science 354 Spring 2010.

Module 2: Assigning IP Addresses in a Multiple Subnet Network

Chapter 13. Disk Storage, Basic File Structures, and Hashing

VirtualCenter Database Performance for Microsoft SQL Server 2005 VirtualCenter 2.5

Chapter 11 I/O Management and Disk Scheduling

Cluster APIs. Cluster APIs

Hardware Performance Optimization and Tuning. Presenter: Tom Arakelian Assistant: Guy Ingalls

Transcription:

Memory Management, Early Systems Single-User Contiguous Scheme Fixed Partitions Dynamic Partitions Deallocation Relocatable Dynamic Partitions Conclusion Single User Configurations Fixed Partitions Dynamic Partitions Relocatable Dynamic Partitions 1

Single-User Contiguous Scheme Each program loaded in its entirety into memory and allocated as much contiguous memory space as needed. If program was too large -- it couldn t be executed. Minimal amount of work done by Memory Manager. Hardware needed : 1) register to store base address; 2) accumulator to track size of program as it is loaded into memory. 2

Algorithm to Load a Job in a Single-user System 1. Store first memory location of program into base register 2. Set program counter equal to address of first memory location 3. Load instructions of program 4. Increment program counter by number of bytes in instructions 5. Has the last instruction been reached? If yes, then stop loading program If no, then continue with step 6 6. Is program counter greater than memory size? If yes, then stop loading. If no, then continue with step 7 7. Load instruction in memory 8. Go to step 3. 3

Fixed (Static) Partitions Attempt at multiprogramming using fixed partitions one partition for each job size of partition designated by reconfiguring the system partitions can t be too small or too large. Critical to protect job s memory space. Entire program stored contiguously in memory during entire execution. Internal fragmentation is a problem. 4

Algorithm to Load a Job in a Fixed Partition 1. Determine job s requested memory size 2. If job_size > size of largest partition then reject job Print appropriate message Go to step 1 to handle next job Else continue with step 3 3. Set counter to 1 4. Do while counter <= number of partitions in memory If job_size > mem_partition_size (counter) then counter = counter + 1 Else If mem_partition_status (counter) = free then load job into mem_partition(counter) change mem_partition_status(counter) to busy go to step 1 Else counter = counter + 1 End do 5. No partition available at this time, put job in waiting queue 6. Go to step 1 5

Simplified Fixed Partition Memory Table (Table 2.1) Partition size Memory address Access Partition status 100K 200K Job 1 Busy 25K 300K Job 4 Busy 25K 325K Free 50K 350K Job 2 Busy 6

Job List : J1 30K J2 50K J3 30K J4 25K Table 2.1 : Main memory use during fixed partition allocation of Table 2.1. Job 3 must wait. Original State After Job Entry 100K Job 1 (30K) Partition 1 Partition 1 Partition 2 25K Job 4 (25K) Partition 2 Partition 3 25K Partition 3 Partition 4 50K Job 2 (50K) Partition 4 7

Dynamic Partitions Available memory kept in contiguous blocks and jobs given only as much memory as they request when loaded. Improves memory use over fixed partitions. Performance deteriorates as new jobs enter the system fragments of free memory are created between blocks of allocated memory (external fragmentation). 8

Dynamic Partitioning of Main Memory & Fragmentation (Figure 2.2) 9

Dynamic Partition Allocation Schemes First-fit: Allocate the first partition that is big enough. Keep free/busy lists organized by memory location (loworder to high-order). Faster in making the allocation. Best-fit: Allocate the smallest partition that is big enough Keep free/busy lists ordered by size (smallest to largest). Produces the smallest leftover partition. Makes best use of memory. 10

First-Fit Allocation Example (Table 2.2) Job List J1 10K J2 20K J3 30K* J4 10K Memory Memory Job Job Internal location block size number size Status fragmentation 10240 30K J1 10K Busy 20K 40960 15K J4 10K Busy 5K 56320 50K J2 20K Busy 30K 107520 20K Free Total Available: 115K Total Used: 40K 11

Best-Fit Allocation Example (Table 2.3) Job List J1 J2 J3 J4 10K 20K 30K 10K Memory Memory Job Job Internal location block size number size Status fragmentation 40960 15K J1 10K Busy 5K 107520 20K J2 20K Busy None 10240 30K J3 30K Busy None 56230 50K J4 10K Busy 40K Total Available: 115K Total Used: 70K 12

First-Fit Algorithm 1. Set counter to 1 2. Do while counter <= number of blocks in memory If job_size > memory_size(counter) then counter = counter + 1 else load job into memory_size(counter) adjust free/busy memory lists go to step 4 End do 3. Put job in waiting queue 4. Go fetch next job 13

First-Fit Memory Request (Table 2.4) Before request After request Beginning address Memory block size Beginning address Memory block size 4075 105 4075 105 5225 5 5225 5 6785 600 *6985 400 7560 20 7560 20 7600 205 7600 205 10250 4050 10250 4050 15125 230 15125 230 24500 1000 24500 1000 14

Best-Fit Algorithm 1. Initialize mem_block(0) = 99999 2. Compute initial_mem_waste = memory_block(0) job_size 3. Initialize subscript = 0 4. Set counter to 1 5. Do while counter <= number of blocks in memory If job_size > mem_size(counter) Then counter = counter + 1 Else mem_waste = mem_size(counter) job_size If initial_mem_waste > mem_waste Then subscript = counter initial_mem_waste = mem_waste counter = counter + 1 End do 6. If subscript = 0 Then put job in waiting queue Else load job into mem_size(subscript) adjust free/busy memory lists 7. Go fetch next job 15

Best-Fit Memory Request (Table 2.5) Before request After request Beginning address Memory block size Beginning address Memory block size 4075 105 4075 105 5225 5 5225 5 6785 600 6785 600 7560 20 7560 20 7600 205 *7800 5 10250 4050 10250 4050 15125 230 15125 230 24500 1000 24500 1000 16

Best-Fit vs. First-Fit First-Fit Increases memory use Memory allocation takes more time Reduces internal fragmentation Best-Fit More complex algorithm Searches entire table before allocating memory Results in a smaller free space (sliver) 17

Release of Memory Space : Deallocation Deallocation for fixed partitions is simple Memory Manager resets status of memory block to free. Deallocation for dynamic partitions tries to combine free areas of memory whenever possible Is the block adjacent to another free block? Is the block between 2 free blocks? Is the block isolated from other free blocks? 18

Algorithm to Deallocate Memory Blocks If job_location is adjacent to 1+ free blocks Then If job_location is between 2 free blocks Then merge all 3 blocks into 1 block mem_size(counter-1) = mem_size(counter-1) + job_size + mem_size(counter+1) Set status of mem_size(counter+1) to null entry Else merge both blocks into one mem_size(counter-1) = mem_size(counter-1) + job_size Else search for null entry in free memory list enter job_size and beginning_address in entry slot set its status to free 19

Case 1: Joining 2 Free Blocks Before Deallocation After Deallocation Beginning Memory Status Beginning Memory Status address block size address block size 4075 105 Free 4075 105 Free 5225 5 Free 5225 5 Free 6785 600 Free 6785 600 Free 7560 20 Free 7560 20 Free (7600) (200) (Busy) 1 *7600 205 Free *7800 5 Free 10250 4050 Free 10250 4050 Free 15125 230 Free 15125 230 Free 24500 1000 Free 24500 1000 Free 20

Case 2: Joining 3 Free Blocks Before Deallocation After Deallocation Beginning Memory Status Beginning Memory Status address block size address block size 4075 105 Free 4075 105 Free 5225 5 Free 5225 5 Free 6785 600 Free 6785 600 Free 7560 20 Free 7560 245 Free (7600) (200) (Busy) 1 * (null) *7800 5 Free 10250 4050 Free 10250 4050 Free 15125 230 Free 15125 230 Free 24500 1000 Free 24500 1000 Free 21

Case 3: Deallocating an Isolated Block Busy List Before Busy List After Beginning Memory Status Beginning Memory Status address block size address block size 7805 1000 Busy 7805 1000 Busy *8805 445 Busy * (null entry) 9250 1000 Busy 9250 1000 Busy 22

Relocatable Dynamic Partitions Memory Manager relocates programs to gather all empty blocks and compact them to make 1 memory block. Memory compaction (garbage collection, defragmentation) performed by OS to reclaim fragmented sections of memory space. Memory Manager optimizes use of memory & improves throughput by compacting & relocating. 23

Compaction Steps Relocate every program in memory so they re contiguous. Adjust every address, and every reference to an address, within each program to account for program s new location in memory. Must leave alone all other values within the program (e.g., data values). 24

Original Assembly Language Program (Figure 2.4) A: EXP 132, 144, 125, 110 ;the data values BEGIN: MOVEI 1,0 ;initialize register 1 MOVEI 2,0 ;initialize register 2 LOOP: ADD 2,A(1) ;add (A + reg 1) to reg 2 ADDI 1,1 ;add 1 to reg 1 CAIG 1,4-1 ;is reg 1 > 4-1? JUMPA LOOP ;if not, go to Loop MOVE 3,2 ;if so, move reg 2 to reg 3 IDIVI 3,4 ;divide reg 3 by 4, EXIT END ;remainder to register 4 ;end 25

Assembly Language Program Loaded into Memory (Figure 2.4) 000000 000000 000132 A: EXP 132,144,125,110 000001 000000 000144 000002 000000 000125 000003 000000 000110 000004 201 01 0 00 000000 BEGIN: MOVEI 1,0 000005 201 02 0 00 000000 MOVEI 2,0 000006 270 02 0 01 000000 LOOP: ADD 2,A(1) 000007 271 01 0 00 000001 ADDI 1,1 000008 307 01 0 00 000003 CAIG 1,4-1 000009 324 00 0 00 000006 JUMPA LOOP 000010 200 03 0 00 000002 MOVE 3,2 000011 231 03 0 00 000004 IDIVI 3,4 000012 047 00 0 00 000012 EXIT 000000 END 26

Program in Memory During Compaction & Relocation Free list & busy list are updated free list shows partition for new block of free memory busy list shows new locations for all relocated jobs Bounds register stores highest location in memory accessible by each program. Relocation register contains value that must be added to each address referenced in program so it can access correct memory addresses after relocation. 27

Memory Before & After Compaction (Figure 2.5) 28

Contents of relocation register & close-up of Job 4 memory area (a) before relocation & (b) after relocation and compaction (Figure 2.6) 29

More Overhead is a Problem with Compaction & Relocation Timing of compaction (when, how often) is crucial. Approaches to timing of compaction: 1. Compact when certain percentage of memory is busy (e.g., 75%). 2. Compact only when jobs are waiting. 3. Compact after certain amount of time. 30

Key Terms address best-fit memory allocation bounds register compaction deallocation dynamic partitions external fragmentation first come first served first-fit memory allocation fixed partitions internal fragmentation K multiprogramming relocatable dynamic partitions relocation relocation register 31