DYNAMIC STORAGE ALLOCATION. Hanan Samet

Similar documents
DYNAMIC STORAGE ALLOCATION. Hanan Samet

GARBAGE COLLECTION METHODS. Hanan Samet

Any modern computer system will incorporate (at least) two levels of storage:

IP Network Design by Modified Branch Exchange Method

MapReduce Optimizations and Algorithms 2015 Professor Sasu Tarkoma

Slotted Random Access Protocol with Dynamic Transmission Probability Control in CDMA System

Gravitational Shift for Beginners

Journal of World s Electrical Engineering and Technology J. World. Elect. Eng. Tech. 1(1): 12-16, 2012

Scaling Location-based Services with Dynamically Composed Location Index

Lecture #22 Pipelining II, Cache I

CS 61C: Great Ideas in Computer Architecture. Pipelining Hazards. Instructor: Senior Lecturer SOE Dan Garcia

COSC 6385 Computer Architecture. - Pipelining

Towards Adaptive Information Merging Using Selected XML Fragments

CS 2461: Computer Architecture 1 Program performance and High Performance Processors

Lecture Topics ECE 341. Lecture # 12. Control Signals. Control Signals for Datapath. Basic Processing Unit. Pipelining

RANDOM IRREGULAR BLOCK-HIERARCHICAL NETWORKS: ALGORITHMS FOR COMPUTATION OF MAIN PROPERTIES

A Two-stage and Parameter-free Binarization Method for Degraded Document Images

THE THETA BLOCKCHAIN

The International Conference in Knowledge Management (CIKM'94), Gaithersburg, MD, November 1994.

A Memory Efficient Array Architecture for Real-Time Motion Estimation

You Are Here! Review: Hazards. Agenda. Agenda. Review: Load / Branch Delay Slots 7/28/2011

Statistics of Images. Ioannis Rekleitis

SORTING IN SPACE HANAN SAMET

A Recommender System for Online Personalization in the WUM Applications

Modelling, simulation, and performance analysis of a CAN FD system with SAE benchmark based message set

Accelerating Storage with RDMA Max Gurtovoy Mellanox Technologies

Image Enhancement in the Spatial Domain. Spatial Domain

High performance CUDA based CNN image processor

UCB CS61C : Machine Structures

Cardiac C-Arm CT. SNR Enhancement by Combining Multiple Retrospectively Motion Corrected FDK-Like Reconstructions

t [ Background removed

Information Retrieval. CS630 Representing and Accessing Digital Information. IR Basics. User Task. Basic IR Processes

a Not yet implemented in current version SPARK: Research Kit Pointer Analysis Parameters Soot Pointer analysis. Objectives

ANALYTIC PERFORMANCE MODELS FOR SINGLE CLASS AND MULTIPLE CLASS MULTITHREADED SOFTWARE SERVERS

Interference-Aware Multicast for Wireless Multihop Networks

Topic 7 Random Variables and Distribution Functions

Evaluation of Partial Path Queries on XML data

Lecture # 04. Image Enhancement in Spatial Domain

Exploring non-typical memcache architectures for decreased latency and distributed network usage.

All lengths in meters. E = = 7800 kg/m 3

A Neural Network Model for Storing and Retrieving 2D Images of Rotated 3D Object Using Principal Components

Evaluation of Partial Path Queries on XML Data

HISTOGRAMS are an important statistic reflecting the

A New Finite Word-length Optimization Method Design for LDPC Decoder

Segmentation of Casting Defects in X-Ray Images Based on Fractal Dimension

Cellular Neural Network Based PTV

A modal estimation based multitype sensor placement method

An Identification Protocol based the secure USB

Analysis of uniform illumination system with imperfect Lambertian LEDs

n If S is in convex position, then thee ae exactly k convex k-gons detemined by subsets of S. In geneal, howeve, S may detemine fa fewe convex k-gons.

Hierarchically Clustered P2P Streaming System

Finding point-pairs. Find Closest Point from Dense Cloud

Modeling a shared medium access node with QoS distinction

Multi-azimuth Prestack Time Migration for General Anisotropic, Weakly Heterogeneous Media - Field Data Examples

Performance Optimization in Structured Wireless Sensor Networks

4.2. Co-terminal and Related Angles. Investigate

Module 6 STILL IMAGE COMPRESSION STANDARDS

How many times is the loop executed? middle = (left+right)/2; if (value == arr[middle]) return true;

FACE VECTORS OF FLAG COMPLEXES

DPICO: A High Speed Deep Packet Inspection Engine Using Compact Finite Automata

A Minutiae-based Fingerprint Matching Algorithm Using Phase Correlation

A Novel Automatic White Balance Method For Digital Still Cameras

Optical Flow for Large Motion Using Gradient Technique

Class 21. N -body Techniques, Part 4

On the Conversion between Binary Code and Binary-Reflected Gray Code on Boolean Cubes

Configuring RSVP-ATM QoS Interworking

In order to learn which questions have been answered correctly: 1. Print these pages. 2. Answer the questions.

sf3 RESTRICTED QUADTREE (VON HERZEN/BARR)

Conversion Functions for Symmetric Key Ciphers

Simulation-Based Test Algorithm Generation and Port Scheduling for Multi-Port Memories

Effective Data Co-Reduction for Multimedia Similarity Search

Computer Architecture. Pipelining and Instruction Level Parallelism An Introduction. Outline of This Lecture

Assessment of Track Sequence Optimization based on Recorded Field Operations

Administrivia. CMSC 411 Computer Systems Architecture Lecture 5. Data Hazard Even with Forwarding Figure A.9, Page A-20

COEN-4730 Computer Architecture Lecture 2 Review of Instruction Sets and Pipelines

Monte Carlo Techniques for Rendering

Obstacle Avoidance of Autonomous Mobile Robot using Stereo Vision Sensor

An Optimised Density Based Clustering Algorithm

arxiv: v2 [physics.soc-ph] 30 Nov 2016

Spiral Recognition Methodology and Its Application for Recognition of Chinese Bank Checks

Adaptation of TDMA Parameters Based on Network Conditions

A VECTOR PERTURBATION APPROACH TO THE GENERALIZED AIRCRAFT SPARE PARTS GROUPING PROBLEM

User Visible Registers. CPU Structure and Function Ch 11. General CPU Organization (4) Control and Status Registers (5) Register Organisation (4)

WIRELESS sensor networks (WSNs), which are capable

(a, b) x y r. For this problem, is a point in the - coordinate plane and is a positive number.

The EigenRumor Algorithm for Ranking Blogs

ANN Models for Coplanar Strip Line Analysis and Synthesis

Parallel processing model for XML parsing

Point-Biserial Correlation Analysis of Fuzzy Attributes

Generalized Grey Target Decision Method Based on Decision Makers Indifference Attribute Value Preferences

BOLT BERANEK AND NEWMAN i K c CONSUITING DEVEIOPMENT RESEARCH THE STRUCTURE OP A LISP SYSTEM USING TWO-LEVEL STORAGE

Getting Started PMW-EX1/PMW-EX3. 1 Rotate the grip with the RELEASE button pressed. Overview. Connecting the Computer and PMW-EX1/EX3

A Caching Algorithm using Evolutionary Game Theory in a File-Sharing System

Concomitants of Upper Record Statistics for Bivariate Pseudo Weibull Distribution

CS 5114: Theory of Algorithms. Sorting. Insertion Sort. Exchange Sorting. Clifford A. Shaffer. Spring 2010

Controlled Information Maximization for SOM Knowledge Induced Learning

Fifth Wheel Modelling and Testing

IP Multicast Simulation in OPNET

Conservation Law of Centrifugal Force and Mechanism of Energy Transfer Caused in Turbomachinery

UNION FIND. naïve linking link-by-size link-by-rank path compression link-by-rank with path compression context. An Improved Equivalence Algorithm

Transcription:

ds0 DYNAMIC STORAGE ALLOCATION Hanan Samet Compute Science Depatment and Cente fo Automation Reseach and Institute fo Advanced Compute Studies Univesity of Mayland College Pak, Mayland 07 e-mail: hjs@umiacs.umd.edu Copyight 1997 Hanan Samet These notes may not be epoduced by any means (mechanical o electonic o any othe) without the expess witten pemission of Hanan Samet

DYNAMIC STORAGE ALLOCATION 6 v 5 g z 81 b ds1 Explicit allocation and deallocation ( feeing o libeating ) of blocks of contiguous stoage locations Issues: 1. how to keep tack of available space and its patitioning usually keep a linked list of available blocks a. elements location of stat of block size size of block pointe to next block in list b. how to ode (i.e., sot ) list size by location (i.e., inceasing ode) by size no ode. how to find a block of b consecutive locations if list soted by location, find fist one with s b (fist fit) a. equies a seach b. but good if want to mege adjacent empty blocks into lage ones upon stoage deallocation if list soted by size, find smallest one with s b (best fit) Ex: fist fit is supeio to best fit equest available aeas fist fit available aeas best fit stat 100,100 100,100 1000 00,100 100,00 1100 00,100 00,00 50 50,100 STUCK! Requests in ode of inceasing size: fist fit is bette Requests in ode of deceasing size: best fit is bette Can give example whee best fit is bette than fist fit

FRAGMENTATION ds Fagmentation esults when too many small blocks ae geneated Solutions: 1. can avoid by choosing a constant k and selecting block a of size s to satisfy the equest fo a block of size b if s b < k eliminates small blocks speeds up seach in fist-fit method as list of blocks is smalle. can avoid inspecting blocks that ae too small in fist-fit by pefoming seach in a cicula manne so that it esumes whee the last block was found. can also avoid by using compaction upon deallocation

LIBERATION ds 1. Want to etun stoage to the AVAIL list as soon as possible implies that can coalesce elements of AVAIL list into lage blocks. Contast with methods based on gabage collection which allocate stoage continuously until exhausting the AVAIL list followed by a pass fo stoage eclamation and compaction. Combining gabage collection with compaction stoage locations must be moved need to execise cae when moving pointe data pesence of elocation egistes obviates some of the poblems, since the pointes could be offset addesses

LIBERATION WITH COALESCING g z 81 b ds Ex: assume a soted AVAIL list by memoy locations i.e., LINK(p) Ω LINK(p)>p coalesce fom below fee next on AVAIL libeated coalesce fom above next on AVAIL libeated coalesce fom below and above next on AVAIL libeated Poblem: each time the algoithm is invoked to libeate block pointed at by p, we must seach though appoximately half the list to locate q such that LINK(q)>p

LIBERATION ALGORITHM ds5 Assume N consecutive wods stating at P0 ae being libeated Algoithm: 1. seach though AVAIL until finding a node Q such that link(q) = P > P0. if P0+N = P then begin /* coalesce fom above */ size(p0) size(p)+n; link(p0) link(p); end else begin link(p0) P; size(p0) N; end;. if Q+size(Q) = P0 then begin /* coalesce fom below */ size(q) size(q)+size(p); /* N was aleady accounted fo in step (above) */ link(q) link(p0); end else link(q) P0;

LIBERATION USING DOUBLY-LINKED LISTS g z 81 b ds6 Data stuctue block inuse=+ inuse size }SIZE { wods inuse fee block size link link inuse= inuse=+ INUSE and SIZE fields 1. easy to locate immediately adjacent blocks to detemine if coalescing is possible. obviate need to sot list of available blocks (AVAIL) in inceasing memoy size. moe complex if sot AVAIL by block size as need to update Doubly-linked AVAIL enables easy emoval of coalesced blocks Ex: inuse fee inuse size inuse= coalesce fom below pev next + libeated - + + coalesce fom above pev + libeated + next coalesce fom below and above pev next pev next + libeated +

BUDDY SYSTEM ds7 Restict block size to be a powe of 1. all blocks of size k stat at location x whee x mod k = 0. given a block stating at location x such that x mod k = 0 BUDDY k (x) = x + k if x mod k+1 = 0 BUDDY k (x) = x k if x mod k+1 = k Ex: BUDDY (10100) = 10000. only buddies can be meged. ty to coalesce buddies when stoage is deallocated k diffeent available block lists one fo each block size When equest a block of size k and none is available: 1. split smallest block j > k into a pai of blocks of size j 1. place block on appopiate AVAIL list and ty again Data stuctue 1. doubly-linked list (not cicula) FREE of available blocks indexed by k links stoed in actual blocks FREE[k] points to fist available block of size k. each block contains INUSE bit SIZE NEXT and PREV links fo FREE list Can get geate vaiety in block sizes using Fibonacci sequence of block sizes so b i = b i 1 +b i and now atio of successive block sizes is / instead of 1/

EXAMPLE OF BUDDY ALGORITHM 5 v g z 81 b ds8 M = 15 1 1 1 11 10 9 8 7 6 5 1 0 I S P N 0 0 0 Ω Ω Ω Ω Ω 0 0 0 0 Ω Ω Ω Ω Ω 0 1 1 1 8 Ω Ω 0 1 1 1 Ω Ω 0 1 0 Ω 10 Ω Ω 0 1 1 1 0 16 Ω 1 Ω Ω k FREE[k] 0 Ω 1 Ω 10 Ω 1 Ω 8 Ω 0 Ω initially, one block of size 16 stating at location 0 is available allocate a block of size allocate blocks of size,, in ode fee the block at location fee the block at location 0 mege block at 0 with its buddy at no futhe meging is possible as the buddy at is in use

BUDDY ALGORITHM NOTES ds9 Assume stoage uns fom locations 0 to m 1 To eseve a block of size k : 1. find smallest j fo which FREE[j] Ω (assume this block stats at location n). emove the block at location n fom FREE[j]. while j>k do begin j j 1; add block at location n+ j to FREE[j]; end; To libeate a block of size k stating at location n: while k m and NOT(INUSE(BUDDY k (n))) do begin emove BUDDY k (n) fom FREE[k]; k k+1; if BUDDY k (n)<n then n BUDDY k (n); end; INUSE flag only needs to be set in fist wod of each block 1. all emaining elements (wods) have thei buddies within the same block. no one outside the block will look fo buddies within the block

OVERFLOW 5 v g z 81 b ds10 At times, have moe stoage allocation equests than available memoy Can pefom gabage collection with compaction but will soon un out of memoy again Altenatively, emove blocks to seconday stoage: 1. keep a doubly-linked list of blocks in use, soted accoding to fequency of use wheneve a block is accessed, move it to font of list like a self-oganizing file Ex: stat C A B C D accessing C causes it to move to the font. cicula list of blocks and a ecently-used bit indicating if the block was accessed since the last time blocks wee emoved to seconday stoage to emove a block, mach down the list looking fo a 0 and eset all 1s that wee encounteed to 0 cuculating pointe ensues that a block eset to 0 will not be checked again fo emoval until all othe blocks have been checked Ex: stat stat 1 1 1 0 1 0 A 0 B 0 1 C D E 0 0 block D is the fist to be emoved access block A block B is emoved next stat