Skip to content

dynle/buddy-memory-allocator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

Buddy Memory Allocator

Screen Shot 2022-06-04 at 2 35 43 PM

Buddy memory allocator is a memory allocation algorithm that divides memory into partitions to try to satisfy a memory request as suitably as as possible.

Wikipedia

This program allows 64 blocks to be allocated and deallocated, and it correctly merges freed blocks. Each time the program splits a block, it adds a ’|’ to show where the split happened. ’-’ represents free blocks, and ’#’ represents in-use blocks. The two numbers printed out as in 0/4 represent the beginning address and number of blocks in a chunk. The program takes three one-letter commands: ’a’ for allocate, ’f’ for free, and ’q’ for quit. The second argument on a line is the number of blocks (for allocate) or the address, or first block number, of the allocated chunk (for free).

Run

Use Python to run buddy-memory-allocator.py.

python buddy-memory-allocator.py

Usage

# 'a' for allocation / numebr of blocks
a 4

# 'f' foor free / the beginning address
f 0

# 'q' for quit
q

License

MIT

About

Buddy memory allocator in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages