3 each thread associated with a process has its own

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ector consists of a mark phase, which marks all reachable and allocated descendents of the root nodes, followed by a sweep phase, which frees each unmarked allocated block. Typically, one of the spare low-order bits in the block header is used to indicate whether a block is marked or not. Our description of Mark&Sweep will assume the following functions, where ptr is defined as typedef void *ptr. 10.10. GARBAGE COLLECTION 549 ¯ ¯ ¯ ¯ ¯ ¯ ¯ ptr isPtr(ptr p): If p points to some word in an allocated block, returns a pointer b to the beginning of that block. Returns NULL otherwise. int blockMarked(ptr b): Returns true if block b is already marked. int blockAllocated(ptr b): Returns true if block b is allocated. void markBlock(ptr b): Marks block b. int length(b): Returns the length in words (excluding the header) of block b. void unmarkBlock(ptr b): Changes the status of block b from marked to unmarked. ptr nextBlock(ptr b): Returns the successor of block in the heap. The mark phase calls the mark f...
View Full Document

Ask a homework question - tutors are online