lect26 - CMSC 216 Introduction to Computer Systems Lecture...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CMSC 216 Introduction to Computer Systems Lecture 26 Heap Management Jan Plane & Pete Keleher {jplane, [email protected] Administrivia • Project 6 – questions? • Practice final exam posted, with answers • Please do course evaluation, at www.CourseEvalUM.umd.edu 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
H EAP M ANAGEMENT Section 10.9, Bryant and O'Hallaron 3 Implementing dynamic allocation Where does memory for a program's heap come from? the program (algorithms of the library functions that implement the heap) makes calls to the OS (system calls) to add memory to the heap of a running process (move the top of heap pointer) – on Linux, this is void *sbrk(int incr) adds at least incr bytes to the end of the program's data segment – the key idea is to get big chunks of memory from the OS and then hand out small regions to the program on demand OS calls can be a hundred times slower than local subroutines How is the memory in the heap managed? – data structures need to be kept to: keep track of what memory is in use, and keep track of where the free memory regions are – calls to malloc() , free() , etc., update these data structures 4
Background image of page 2
Heap Manager Requirements The heap manager must be able to handle arbitrary sequences of requests to allocate and deallocate memory other than the constraint that a free() on an address can't occur before it was returned by an earlier call to malloc() , calloc(), or realloc() It must respond immediately it can't wait for other requests (can’t buffer the requests) All data it uses must be stored in the heap itself it can't use any auxiliary data structures It must be aligned
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

lect26 - CMSC 216 Introduction to Computer Systems Lecture...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online