Phone:

+(886) 909 756 966

Email:
moneychien20639@gmail.com

© 2024 Yu-Hang

Course:

Introduction to Computer Systems (15-513)

Time Spent:

80 hours

Source Code:
to github

Malloc Lab

This program is a dynamic memory allocator for a 64-bit architecture. It uses an segregated free list with boundary tags for coalescing free blocks. The allocator provides `malloc`, `free`, `realloc`, and `calloc` functions that manage memory in the heap. It maintains 15 lists of free blocks to quickly find available memory chunks.

Key Design Decisions:
- The allocator uses a segregated free list with 15 free lists to manage free blocks of various sizes.
- Each block has a header and footer containing the size and allocation status.
- Coalescing of free blocks is done eagerly whenever a block is freed.
- Blocks are aligned to 16 bytes to satisfy alignment requirements.

Usage:
- `malloc(size_t size)`: Allocates a block of memory of the given size.
- `free(void *ptr)`: Frees a previously allocated block.
- `realloc(void *ptr, size_t size)`: Resizes a previously allocated block.
- `calloc(size_t elements, size_t size)`: Allocates and zeroes a block of memory.

To modify this program:
- Understand the structure of `block_t` and how headers and footers are used.
- Ensure that any changes to block size calculations maintain the alignment.
- Modify the heap checker functions to add additional integrity checks.


  • C
  • Dynamic Memory Allocator
  • Segregated Free List
  • Memory Allocation
  • Heap Management
  • Performance Optimization
  • 64-bit Architecture