Skip to content

A Python-based simulator showcasing memory management concepts such as allocation strategies, segmentation, pagination, swapping, and TLB. Interactive examples implemented in Jupyter notebooks

License

Notifications You must be signed in to change notification settings

lorenzomaiuri-dev/memory-management-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Memory Management Examples

Stargazers License LinkedIn

A Python library to simulate memory management techniques like allocation, segmentation, swapping, TLB, pagination and the Buddy System using Jupyter notebooks.

Table of Contents

Description

The Memory Management Examples repository demonstrates key memory management concepts implemented in Python using Jupyter notebooks. The goal is to provide clear, visual, and interactive examples of how memory is managed in an operating system, with a focus on the following concepts:

  • Segmentation: Dividing memory into variable-sized blocks.
  • Memory Allocation: Implementing allocation strategies such as First-fit, Best-fit, and Worst-fit.
  • Swapping: Managing processes in limited memory spaces.
  • Translation Lookaside Buffer (TLB): A cache to speed up virtual memory access.
  • Pagination: Implementing page tables and a paging system.
  • Buddy System: Implementing the buddy memory allocation

This project is designed for anyone learning about memory management or those looking to simulate memory management techniques in Python.

Requirements

To run the examples, you need python >= 3.10 and the required dependencies installed

Installation

  1. Clone this repository:

     git clone https://github.com/lorenzomaiuri-dev/memory-management-examples.git
     cd memory-management-examples
  2. Create a virtual environment (optional but recommended):

    python -m venv venv
    
    source venv/bin/activate  # On Linux/Mac
    venv\Scripts\activate  # On Windows
  3. Install the dependencies

    pip install -r requirements.txt
    

Usage

You can explore the concepts interactively by running the Jupyter notebooks
Here’s a list of Jupyter notebooks you can run to see the different memory management strategies in action:

  • segmentation.ipynb: simulates memory allocation using segmentation. This simulation models physical memory, allocates segments for processes, and displays the memory allocation
  • swapping_FIFO.ipynb: simulates swapping, a memory management technique where an entire process is moved between memory and disk (secondary storage). This simulation includes the concepts of physical memory, a "swap area" (disk), and process swapping.
  • allocation.ipynb: simulates First Fit, Best Fit, and Worst Fit allocation algorithms for dynamic memory allocation. This simulation implement and compare these memory allocation strategies for managing free memory blocks in a contiguous memory system
  • pagination.ipynb: simulates pagination and the FIFO page replacement policy
  • TLB.ipynb: simulates how a TLB (Translation Lookaside Buffer) caches virtual-to-physical address mappings to speed up address translation
  • buddy_system.ipynb: simulates how the Buddy Memory Allocation works, splitting the memory into halfs to try to satisfy a memory request as suitably as possible

Contributing

Contributions are welcome! If you'd like to contribute to this project, please follow these steps:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/your-feature)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push the branch (git push origin feature/your-feature)
  5. Open a Pull Request

Please ensure all pull requests pass the existing tests and include new tests for any added functionality

License

This project is licensed under the GPL-3.0 License. See the LICENSE file for more details

Acknowledgments

Special thanks to all contributors and resources that made this project possible