






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Dynamic Storage Allocation, User-Level View, Policies Mechanism
Typology: Slides
1 / 30
This page cannot be seen from the preview
Don't miss anything!























User-level view
Policies
Mechanisms
class14.ppt
Introduction to Computer Systems
class14.ppt
Memory Matters
It must be allocated and managed
Many applications are memory dominated
Effects are distant in both time and space
performanceCache and virtual memory effects can greatly affect program
major speed improvementsAdapting program to characteristics of memory system can lead to
class14.ppt
Reserved for kernel
Reserved for shared libraries
and dynamic loader
Available for heap
Heap (via malloc())
Grows up
Bss segment
Text segmentData segment
Stack
Not accessible
Available for stack
Grows down to zero
Not accessible by convention
(64KB)
$sp $gp
0x
0000
0000
0000
0x
0000
0000
ffff
0x
0000
0001
0000
0x
0000
1fff
ffff
0x
0001
2000
0000
0x
03ff
7fff
ffff
0x
03ff
8000
0000
0x
03ff
ffff
ffff
0x
0400
0000
0000
0xffff
fbff
ffff
ffff
0xffff
fc
0000
0000
0xffff
ffff
ffff
ffff
class14.ppt
if successful:
if unsuccessful:
returns block pointed at by p to pool of available memory
p must come from a previous call to malloc().
class14.ppt
class14.ppt
Can issue arbitrary sequence of allocation and free requests
Free requests must correspond to an allocated block
Can’t control number or size of allocated blocks
Must respond immediately to all allocation requests
Must allocate blocks from free memory
Must align blocks so they satisfy all alignment requirements
Can only manipulate and modify free memory
Can’t move the allocated blocks once they are allocated
class14.ppt
(external) fragmentation is the inability to reuse free
creating holes.possible because applications can free blocks in any order, potentially
Number and sizes of holes,
Future program behavior.
class14.ppt
Qualitatively, C has fewer and bigger holes.
But fragmentation occurs only if program needs a large block.
Still, C is probably less likely to encounter problems.
C B A
class14.ppt
But “best fit” doesn’t always work best either
class14.ppt
oops!
class14.ppt
(3) Allocate the first block(2) Split the block into two free blocks(1) Find a free block that is big enough
class14.ppt
2
(2) merge any adjacent free blocks into a single free block(1) free the block
immediate (performed at every free request)
deferred (performed every k free requests or when necessary)
class14.ppt
class14.ppt
feasible free block).
Placement policy determines which feasible free block
Where do we place the allocated block?Each of these free blocks is feasible.