Authors: Sahaj Singh
This repository contains the implementation of a multi-threaded memory allocator. The allocator uses various memory management techniques discussed in class and is based on the provided code. The allocator supports First Fit, Best Fit, and Worst Fit algorithms for memory allocation.
Clone the repository to your local machine.
git clone https://github.com/yourusername/multi-threaded-memory-allocator.git
- Initialization of the memory allocator.
- Allocation and deallocation interfaces.
- Metadata management.
- Compaction support.
- Statistics reporting.
- Multi-threading support.
- Uninitialization.
- Initialize the allocator with the desired memory size and allocation algorithm.
initialize_allocator(1024, FIRST_FIT);
- Allocate and deallocate memory.
int* p = (int*)allocate(sizeof(int)); if (p != NULL) { // do_some_work(p); deallocate(p); }
- Perform compaction and update pointers.
void* before[100]; void* after[100]; int count = compact_allocation(before, after); for (int i = 0; i < count; ++i) { // Update pointers }
- Get statistics and available memory.
struct Stats stats; get_statistics(&stats); int available_mem = available_memory();
- Destroy the allocator to prevent memory leaks.
destroy_allocator();
main.c
contains a main function that tests the allocator. Feel free to add your own test cases for more thorough testing. We may change the test cases or add more for actual grading.
This project is licensed under the MIT License
- Assignment instructions and base code provided by the course instructor for CMPT 300, Steven Ko.