|
1 | 1 | # Linux Memory Manager |
2 | 2 |
|
3 | | -This project provides a comprehensive memory management solution for Linux systems. It includes various components and utilities to efficiently manage memory allocation and deallocation, optimizing memory usage in applications. |
| 3 | +This project provides a comprehensive and optimized memory management solution tailored for Linux systems. It implements a custom heap memory manager, offering enhanced control over memory allocation and deallocation processes, which is critical for high-performance and resource-constrained applications. |
4 | 4 |
|
5 | | -## Features |
6 | | -- **Heap Memory Manager (HMM)**: Implements a flexible and efficient heap memory management system, replacing standard `malloc` and `free` functions with optimized versions. |
7 | | -- **GLib Thread (GLThread)**: Offers a generic linked list implementation using GLib for thread-safe operations. |
8 | | -- **Memory Manager Test Suite**: Includes a test suite to validate the functionality and performance of the memory manager under various scenarios. |
9 | | -- **Shared and Static Libraries**: Supports building both shared and static libraries, providing flexibility in integration with different applications. |
| 5 | +## Table of Contents |
| 6 | +1. [Introduction](#introduction) |
| 7 | +2. [Linux Memory Management Overview](#linux-memory-management-overview) |
| 8 | + - [Why Custom Memory Management?](#why-custom-memory-management) |
| 9 | +3. [Project Features](#project-features) |
| 10 | +4. [Project Structure](#project-structure) |
| 11 | +5. [Building the Project](#building-the-project) |
| 12 | + - [Building the Library](#building-the-library) |
| 13 | + - [Running Tests](#running-tests) |
| 14 | + - [Integration with Applications](#integration-with-applications) |
| 15 | +6. [Documentation](#documentation) |
| 16 | +7. [Contributing](#contributing) |
| 17 | +8. [License](#license) |
| 18 | +9. [Acknowledgments](#acknowledgments) |
10 | 19 |
|
11 | | -## Usage |
12 | | -1. **Building the Library**: |
13 | | - - Run `make all` to build the library and test suite. |
14 | | - - Use `make static` or `make shared` to build the library as a static or shared object, respectively. |
| 20 | +--- |
15 | 21 |
|
16 | | -2. **Running Tests**: |
17 | | - - After building, execute the default test suite by running the `hmm` executable. |
18 | | - - Optionally, run specific tests or modify the test suite according to your requirements. |
| 22 | +## Introduction |
19 | 23 |
|
20 | | -3. **Integration with Applications**: |
21 | | - - Link your application with the generated library (`libhmm.a` for static or `libhmm.so` for shared) to leverage the memory management features. |
| 24 | +Memory management is a critical aspect of system programming, particularly in environments where resource efficiency and performance are paramount. This project presents a custom Heap Memory Manager (HMM) designed specifically for Linux systems, offering an alternative to the standard `malloc` and `free` functions with more efficient, flexible, and robust memory management capabilities. |
22 | 25 |
|
23 | | -## Documentation |
24 | | -- Detailed documentation and API references are available in the project website: [Linux Memory Manager Documentation](https://mahmoud-abdelraouf.github.io/STM_System-Programming-under-Linux/) |
| 26 | +## Linux Memory Management Overview |
| 27 | + |
| 28 | +### Why Custom Memory Management? |
| 29 | + |
| 30 | +In typical Linux applications, memory management is handled by the system's allocator, which uses functions like `malloc`, `calloc`, and `free`. While these standard functions are sufficient for many applications, they may not provide the level of control, efficiency, or customization required for certain high-performance or specialized applications. This project addresses these limitations by offering: |
| 31 | + |
| 32 | +- **Improved Performance:** Custom memory allocation algorithms can reduce fragmentation and enhance performance. |
| 33 | +- **Thread Safety:** The GLib Thread (GLThread) module provides a thread-safe linked list implementation, essential for concurrent applications. |
| 34 | +- **Memory Usage Optimization:** The HMM system is designed to make better use of available memory, reducing wastage and improving overall application efficiency. |
| 35 | + |
| 36 | +## Project Features |
| 37 | + |
| 38 | +- **Heap Memory Manager (HMM):** A robust memory management system that replaces the standard dynamic memory allocation functions with custom, optimized alternatives. |
| 39 | +- **GLib Thread (GLThread):** A generic, thread-safe linked list implementation built using GLib, facilitating safe and efficient multi-threaded operations. |
| 40 | +- **Memory Manager Test Suite:** A comprehensive test suite that rigorously tests the memory manager's functionality and performance across various scenarios, ensuring reliability and robustness. |
| 41 | +- **Support for Static and Shared Libraries:** The project can be built as either a static library (`.a`) or a shared library (`.so`), providing flexibility in how it can be integrated into different applications. |
| 42 | + |
| 43 | +## Project Structure |
| 44 | + |
| 45 | +The project is organized into several directories, each serving a specific purpose: |
| 46 | + |
| 47 | +``` |
| 48 | +. |
| 49 | +├── src/ # Source files containing the core logic of the project |
| 50 | +│ ├── datatype_size_lookup.c # Handles datatype size lookups |
| 51 | +│ ├── glthread.c # GLib-based thread-safe linked list implementation |
| 52 | +│ ├── memory_manager.c # Core heap memory manager implementation |
| 53 | +│ ├── memory_manager_test.c # Test suite for the memory manager |
| 54 | +│ ├── parse_datatype.c # Utilities for parsing datatypes |
| 55 | +├── include/ # Header files defining interfaces and structures |
| 56 | +│ ├── colors.h # Utilities for color-coded terminal output |
| 57 | +│ ├── datatype_size_lookup.h # Header for datatype size lookup functions |
| 58 | +│ ├── glthread.h # Header for GLib thread-safe linked list |
| 59 | +│ ├── memory_manager.h # Header for heap memory manager |
| 60 | +│ ├── memory_manager_api.h # API definitions for memory management |
| 61 | +│ ├── parse_datatype.h # Header for datatype parsing utilities |
| 62 | +├── lib/ # Compiled libraries (static and shared) |
| 63 | +│ ├── libhmm.a # Static library for HMM |
| 64 | +│ ├── libhmm.so # Shared library for HMM |
| 65 | +├── bin/ # Compiled executables and object files |
| 66 | +│ ├── hmm # Executable test suite for the memory manager |
| 67 | +│ ├── *.o # Object files generated during compilation |
| 68 | +├── docs/ # Documentation and Doxygen configuration |
| 69 | +│ ├── Doxyfile # Configuration file for generating project documentation |
| 70 | +├── Makefile # Makefile for automating build and test processes |
| 71 | +├── LICENSE # License file outlining the terms of use |
| 72 | +└── README.md # This README file |
| 73 | +``` |
| 74 | + |
| 75 | +## Building the Project |
| 76 | + |
| 77 | +### Building the Library |
| 78 | + |
| 79 | +To build the project, ensure that you have `gcc` and `make` installed on your system. You can then use the following commands: |
| 80 | + |
| 81 | +- **Build Everything:** |
| 82 | + ```sh |
| 83 | + make all |
| 84 | + ``` |
| 85 | + This command compiles all source files, creates object files, and links them to produce the `hmm` executable, as well as the static and shared libraries. |
| 86 | + |
| 87 | +- **Build Static Library Only:** |
| 88 | + ```sh |
| 89 | + make static |
| 90 | + ``` |
| 91 | + This builds only the static library (`libhmm.a`). |
| 92 | + |
| 93 | +- **Build Shared Library Only:** |
| 94 | + ```sh |
| 95 | + make shared |
| 96 | + ``` |
| 97 | + This builds only the shared library (`libhmm.so`). |
| 98 | + |
| 99 | +### Running Tests |
| 100 | + |
| 101 | +After building, you can run the test suite to verify the memory manager's functionality: |
25 | 102 |
|
26 | | -## EditorConfig: |
27 | | - - The project includes an `.editorconfig` file to ensure consistent coding styles and formatting across different editors and IDEs. |
| 103 | +- **Run All Tests:** |
| 104 | + ```sh |
| 105 | + ./bin/hmm |
| 106 | + ``` |
| 107 | + The test suite is comprehensive and covers a wide range of scenarios, ensuring the robustness of the memory manager. |
| 108 | + |
| 109 | +### Integration with Applications |
| 110 | + |
| 111 | +To use the memory manager in your application, link your application with the generated library: |
| 112 | + |
| 113 | +- **Static Linking:** |
| 114 | + Include the static library `libhmm.a` in your build process. |
28 | 115 |
|
| 116 | +- **Shared Linking:** |
| 117 | + Include the shared library `libhmm.so` and ensure it is in your system's library path. |
| 118 | + |
| 119 | +```sh |
| 120 | +gcc -o myapp myapp.c -Llib -lhmm |
| 121 | +``` |
| 122 | + |
| 123 | +This command compiles `myapp.c` and links it with the `hmm` library. |
| 124 | + |
| 125 | +## Documentation |
| 126 | + |
| 127 | +Detailed documentation is generated using Doxygen and is available in the `docs/` directory. You can also access the documentation online at the [Linux Memory Manager Documentation](https://mahmoud-abdelraouf.github.io/STM_System-Programming-under-Linux/). |
| 128 | + |
| 129 | +To generate the documentation locally, run: |
| 130 | + |
| 131 | +```sh |
| 132 | +make doc |
| 133 | +``` |
| 134 | + |
| 135 | +This will produce HTML documentation that can be viewed in any web browser. |
| 136 | + |
29 | 137 | ## Contributing |
30 | | -- Contributions are welcome! Fork the repository, make your changes, and submit a pull request. |
31 | | -- Report any issues or suggestions by opening an issue on GitHub. |
| 138 | + |
| 139 | +We welcome contributions from the community! Here’s how you can contribute: |
| 140 | + |
| 141 | +1. **Fork the Repository:** Start by forking the project repository. |
| 142 | +2. **Create a Branch:** Develop your feature or fix in a new branch. |
| 143 | +3. **Submit a Pull Request:** Once your changes are ready, submit a pull request for review. |
| 144 | +4. **Report Issues:** If you find any bugs or have suggestions, please open an issue on GitHub. |
| 145 | + |
| 146 | +### Coding Standards |
| 147 | + |
| 148 | +Please adhere to the coding standards outlined in the `.editorconfig` file to ensure consistency across the project. |
32 | 149 |
|
33 | 150 | ## License |
34 | | -This project is licensed under the MIT License. See the [LICENSE](../../../LICENSE) file for details. |
35 | 151 |
|
36 | | ---- |
| 152 | +This project is licensed under the MIT License. See the [LICENSE](../../../LICENSE) file for more details. |
| 153 | + |
| 154 | +## Acknowledgments |
37 | 155 |
|
38 | | -*This project is part of the Linux System Programming course offered by STMicroelectronics Egypt.* |
| 156 | +This project is a part of the Linux System Programming course offered by STMicroelectronics Egypt. Special thanks to the course instructors and contributors for their valuable input and guidance. |
0 commit comments