https://github.com/dynle/buddy-memory-allocator
Buddy memory allocator in python
https://github.com/dynle/buddy-memory-allocator
Last synced: about 1 year ago
JSON representation
Buddy memory allocator in python
- Host: GitHub
- URL: https://github.com/dynle/buddy-memory-allocator
- Owner: dynle
- Created: 2022-05-06T03:38:01.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-04T05:43:10.000Z (almost 4 years ago)
- Last Synced: 2025-02-06T16:05:54.493Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Buddy Memory Allocator
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](https://en.wikipedia.org/wiki/Buddy_memory_allocation)
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.
```bash
python buddy-memory-allocator.py
```
## Usage
```bash
# 'a' for allocation / numebr of blocks
a 4
# 'f' foor free / the beginning address
f 0
# 'q' for quit
q
```
## License
[MIT](https://choosealicense.com/licenses/mit/)