Skip to content

abi-sheks/m-id-alloc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

(Mid)alloc

Pretty self explanatory. Wanted to implement a memory allocator as described in Operating Systems : Three Easy Pieces's chapter on free memory management

Implementation

The program uses a simple mmap syscall to get a page aligned pointer of the designated amount, and presents this as the heap to the user.
I've currently implemented a first-fit style algorithm that iterates over a free list of chunks and allocates the requested space, segments the rest to prevent internal fragmentation. The header for each chunk lives in the actual allocated region and not some separate structure, which has lead to some arcane pointer arithmetic. I've sprinkled in comments where i can to ease this.

Limitations

Currently not implemented coalescing, leading to fragmentation. This implementation is absolutely not memory safe, you can infact write invalid parts of memory and mess things up. sbrk not used in case of large requests, program simply returns with error.

About

memory alloc routine but its mid

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published