Skip to content

Commit 6b66263

Browse files
committed
update the all project
1 parent 9fe8308 commit 6b66263

File tree

21 files changed

+162
-74
lines changed

21 files changed

+162
-74
lines changed
Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
.PHONY: clean_all clean_obj doc
22

3-
cc = gcc
4-
CFLAGS = -Wall -Wextra
3+
CC = gcc
4+
CFLAGS = -Wall -Wextra -Iinclude
55

6-
#List of Source files
7-
SRC = $(wildcard *.c)
6+
# List of Source files
7+
SRC = $(wildcard src/*.c)
88

99
# List of header files
10-
HDR = $(wildcard *.h)
10+
HDR = $(wildcard include/*.h)
1111

12-
#List of Source files except the memory_manager_test
13-
LIB_SRC = $(filter-out memory_manager_test.c, $(wildcard *.c))
12+
# List of Source files except the memory_manager_test
13+
LIB_SRC = $(filter-out src/memory_manager_test.c, $(wildcard src/*.c))
1414

1515
# List of object files
16-
OBJ = $(SRC:.c=.o)
16+
OBJ = $(SRC:src/%.c=bin/%.o)
1717

1818
# List of object files for shared build
19-
OBJ_SHARED = $(LIB_SRC:.c=_shared.o)
19+
OBJ_SHARED = $(LIB_SRC:src/%.c=bin/%_shared.o)
2020

2121
# List of object files for static build
22-
OBJ_STATIC = $(LIB_SRC:.c=_static.o)
22+
OBJ_STATIC = $(LIB_SRC:src/%.c=bin/%_static.o)
2323

2424
# Name of the executable
25-
TARGET = hmm
25+
TARGET = bin/hmm
2626

2727
# Name of the static library
28-
STATIC_LIB = lib$(TARGET).a
28+
STATIC_LIB = lib/lib$(TARGET).a
2929

3030
# Name of the shared library
31-
SHARED_LIB = lib$(TARGET).so
31+
SHARED_LIB = lib/lib$(TARGET).so
3232

3333
# Command to remove files
3434
RM = rm -f
@@ -52,25 +52,26 @@ shared: $(OBJ_SHARED)
5252
$(RM) $(OBJ_SHARED)
5353

5454
# Rule to compile C source files into object files
55-
%.o: %.c $(HDR)
55+
bin/%.o: src/%.c $(HDR)
5656
$(CC) $(CFLAGS) -c $< -o $@
5757

5858
# Rule to compile C source files to object files for shared build
59-
%_shared.o: %.c $(HDR)
59+
bin/%_shared.o: src/%.c $(HDR)
6060
$(CC) $(CFLAGS) -fPIC -c $< -o $@
6161

6262
# Rule to compile C source files to object files for static build
63-
%_static.o: %.c $(HDR)
63+
bin/%_static.o: src/%.c $(HDR)
6464
$(CC) $(CFLAGS) -c $< -o $@
6565

6666
# Clean target
6767
clean_all:
68-
$(RM) $(TARGET) $(OBJ) $(OBJ_STATIC) $(OBJ_SHARED) $(STATIC_LIB) $(SHARED_LIB)
68+
$(RM) bin/* lib/*
6969

7070
# Clean object files
7171
clean_obj:
72-
$(RM) $(OBJ_SHARED) $(OBJ_STATIC)
72+
$(RM) bin/*.o bin/*_shared.o bin/*_static.o
7373

7474
# Generate documentation
7575
doc:
76-
doxygen Doxyfile
76+
doxygen docs/Doxyfile
77+
Lines changed: 142 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,156 @@
11
# Linux Memory Manager
22

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.
44

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)
1019

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+
---
1521

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
1923

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.
2225

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:
25102

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.
28115

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+
29137
## 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.
32149

33150
## License
34-
This project is licensed under the MIT License. See the [LICENSE](../../../LICENSE) file for details.
35151

36-
---
152+
This project is licensed under the MIT License. See the [LICENSE](../../../LICENSE) file for more details.
153+
154+
## Acknowledgments
37155

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.

intermediate/tasks/heap-memory-manager/source-code/Doxyfile renamed to intermediate/tasks/heap-memory-manager/docs/Doxyfile

File renamed without changes.

intermediate/tasks/heap-memory-manager/source-code/README.doxygen.md renamed to intermediate/tasks/heap-memory-manager/docs/README.doxygen.md

File renamed without changes.

intermediate/tasks/heap-memory-manager/project-documentation/gperf.md renamed to intermediate/tasks/heap-memory-manager/docs/gperf.md

File renamed without changes.

intermediate/tasks/heap-memory-manager/project-documentation/heap-memory-manager.pptx renamed to intermediate/tasks/heap-memory-manager/docs/heap-memory-manager.pptx

File renamed without changes.

intermediate/tasks/heap-memory-manager/project-documentation/heap.png renamed to intermediate/tasks/heap-memory-manager/docs/heap.png

File renamed without changes.

intermediate/tasks/heap-memory-manager/source-code/colors.h renamed to intermediate/tasks/heap-memory-manager/include/colors.h

File renamed without changes.

intermediate/tasks/heap-memory-manager/source-code/datatype_size_lookup.h renamed to intermediate/tasks/heap-memory-manager/include/datatype_size_lookup.h

File renamed without changes.

intermediate/tasks/heap-memory-manager/source-code/glthread.h renamed to intermediate/tasks/heap-memory-manager/include/glthread.h

File renamed without changes.

0 commit comments

Comments
 (0)