Skip to content

Efficiently manage memory with a multi-threaded allocator supporting First Fit, Best Fit, and Worst Fit allocation algorithms.

License

Notifications You must be signed in to change notification settings

SatireSage/Multi-threaded-Memory-Allocator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-threaded Memory Allocator

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.

Getting Started

Clone the repository to your local machine.

git clone https://github.com/yourusername/multi-threaded-memory-allocator.git

Features

  1. Initialization of the memory allocator.
  2. Allocation and deallocation interfaces.
  3. Metadata management.
  4. Compaction support.
  5. Statistics reporting.
  6. Multi-threading support.
  7. Uninitialization.

Usage

  1. Initialize the allocator with the desired memory size and allocation algorithm.
initialize_allocator(1024, FIRST_FIT);
  1. Allocate and deallocate memory.
int* p = (int*)allocate(sizeof(int)); if (p != NULL) { // do_some_work(p); deallocate(p); }
  1. 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 }
  1. Get statistics and available memory.
struct Stats stats; get_statistics(&stats); int available_mem = available_memory();
  1. Destroy the allocator to prevent memory leaks.
destroy_allocator();

Testing

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.

License

This project is licensed under the MIT License

Acknowledgments

  • Assignment instructions and base code provided by the course instructor for CMPT 300, Steven Ko.

About

Efficiently manage memory with a multi-threaded allocator supporting First Fit, Best Fit, and Worst Fit allocation algorithms.

Resources

License

Stars

Watchers

Forks

Packages

No packages published