Download presentation
Presentation is loading. Please wait.
Published byDamon Cummings Modified over 8 years ago
1
Storage Management - Chap 10 MANAGING A STORAGE HIERARCHY on-chip --> main memory --> 750ps - 8ns 10 - 90 ns. 128kb - 16mb 2gb -1 tb. RATIO 1 10 hard disk --> cartridge tape system 10 - 50 ms. seconds 1gb - 1 tb. infinite RATIO:100,000 10,000,000
2
Storage Management Algorithms Fetch -- what object’s storage to bring into memory -- SWAP IN Placement -- what empty slot to use to satisfy a storage request Replacement -- what used slot(s) to free to satisfy a storage request -- SWAP OUT
3
New and Malloc 1. Round the requested size; e.g. to an aligned memory address or minimum block size. Results in internal fragmentation. 2. Search the free space data structure 3. Split the block(s) found, if required Free 1. Coalesce multiple free blocks into one
4
Fixed-Size Requests 1. Linked list or bit map data structure Varying-Size Requests 1. Bit map data structure Results in small unusable fragments, external fragmentation May require de-fragmentation routine 2. Overhead of the data structure is referred to as table fragmentation
5
Bit Map Example 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 0 1 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 allocate(3) returns 4 0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 allocate(5) returns 13 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 free(11, 2) 0 1 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1
6
Program Model Multiple Segments, consisting of at least Code, Data, Stack, Heap
7
Requirements It should be possible to control access to an segment. For example, writing over a procedure should be illegal. It should be possible to validate access to an segment. The arguments to a procedure should always be of the correct type and it should not be possible for a procedure to access segments outside its sphere of influence (principle of least privilege). The size of a segment can vary dynamically and be arbitrarily large. Each segment can be shared in a controlled manner among any number of processes. A segment can dynamically link to other segments by referring to their symbolic names at execution time.
8
Hardware Placement Options
9
Hardware Placement Support NONE Static Relocation Onion Skin Algorithm Operating System 0 Program One 100,000 Top of Program Two
10
Hardware Placement Support One Relocation Register (base/limit) Dynamic Relocation Operating System 0 Program One 100,000 All of Program Two 250,000 PHYSICAL ADDRESSES 0 0 0 LOGICAL ADDRESSES Base=0 Limit=99,999 Base=100,000 Limit=249,999 Base=250,000 Limit=299,999
11
Hardware Placement Support Two Relocation Registers (base/limit) One for Code, One for Data/Stack Operating System 0 DATA STACK V ^ CODE 100,000 All of Program Two 250,000 PHYSICAL ADDRESSES 0 0 0 LOGICAL ADDRESSES Limit=249,999 Base=150,000 Limit=149,999 Base=100,000
12
Hardware Placement Support Multiple Relocation Registers SEGMENT TABLE LOGICAL ADDRESS OFFSETSEGMENT NO. SEGMENT TABLE PHYSICAL ADDRESS OFFSETSEGMENT BASE ADDR.
13
Hardware Placement Support Multiple Segments
14
Segments Vary in Size SO We still have the external fragmentation problem BUT We meet all the requirements for managing our Program Model
15
Paging to Solve Placement Make all requests the same size
16
Paging Solves Placement Only but not Program Model
17
Replacement What is a process’ page fault rate? t - the access time to main store T - the access time to a page on disk f - the fraction of a program kept in main store. p(f) - the average number of page faults per store reference as a function of f (0<=p(f)<=1).
18
Replacement What is a process’ page fault rate? FAULT INTERARRIVAL TIME >= PAGE TRANSFER TIME FROM DISK t/p(f) >= T t/(1-f) >= T assume random f >= 1 - t/T t = 50ns T = 5ms t/T = 1/100,000
19
Conclusion A program with a random page reference pattern is BAD!! Luckily, for loops, arrays, recursion, stack access all increase Program Locality
20
Replacement Algorithms SCOPE –Global : take pages from anybody –Local : only take pages from process that caused the page-not-in-memory fault ALLOCATION –Fixed : physical memory per process is limited –Variable : physical memory per process can grow or shrink during execution
21
Replacement Algorithms page reference trace 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 TIME 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 1 2 2 3 4 1 1 2 5 1 2 3 3 4 5 Refs 5 PAGES, 15 TIME PERIODS
22
Replacement Algorithms least-recently used
23
CANNOT IMPLEMENT IN PRACTICE The little matter of a stack of thousands of page #s LRU Approximation Add bits to each page table entry DIRTY - set on a write ACCESSED - set on a read/write
24
LRU Approximation Clock Algorithm At certain clock ticks, –Step a sweep pointer through every page table for a certain number of entries e.g. 100 IF THE PAGE TABLE POINTS TO PHYSICAL MEMORY –DIRTY ACCESSED ACTION – F F Take that page away – F T Turn ACCESSED off – T T Turn ACCESSED off – T F Write page to disk (clean) then turn DIRTY off
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.