This project implements storage management for a minimal operating system, written in x86 assembly AT&T. It features two distinct memory layouts (unidimensional and bidimensional), each with a set of core operations, and includes a CONCRETE functionality for dynamic file loading via UNIX syscalls. The project demonstrates low-level memory handling and is an excellent educational resource for understanding operating system fundamentals.
- Allocate contiguous blocks for file storage.
- Retrieve file block ranges by descriptor.
- Delete files and free memory blocks.
- Compact memory through defragmentation.
- Store files in a 2D grid of memory blocks.
- Retrieve memory ranges using start and end coordinates.
- Perform bidimensional defragmentation to optimize memory usage.
- Uses UNIX syscalls to load real files from a specified directory.
- Dynamically calculates descriptors and file sizes.
- Handles descriptor conflicts and skips redundant entries.
- Allocates memory blocks for files.
- Checks for available space and allocates contiguous memory if possible.
- Outputs the range of allocated blocks or
(0, 0)if the operation fails.
- Locates a file in memory using its descriptor.
- Outputs the memory range where the file resides or
(0, 0)if not found.
- Frees memory occupied by a file identified by its descriptor.
- Ensures the memory becomes available for future allocations.
- Compacts memory to reduce fragmentation:
- For unidimensional memory, moves files to the beginning of the block.
- For bidimensional memory, consolidates files towards the top-left corner of the grid.
-
Dynamically loads files from a directory into memory.
-
Uses UNIX syscalls for raw file operations:
- Open Directory: Uses
opensyscall to access the specified path. - Read Metadata: Retrieves file sizes and calculates descriptors using modulo arithmetic
((fd % 255) + 1). - Add Files: Allocates memory for valid files, skipping duplicates or those exceeding capacity.
- Open Directory: Uses
-
Outputs:
- File descriptor, size, and memory range for each added file.
(0, 0)for skipped files due to descriptor conflicts or insufficient space.
5
/path/to/directory
The 132_Baca_IonutAdelin_0.s is unidimensional and the 132_Baca_IonutAdelin_1.s is the bidimensional case.
- Linear array of fixed-size blocks.
- Uses contiguous allocation for simplicity and efficiency.
- 2D grid structure with row-major storage.
- Allows allocation of rectangular memory regions.
- Implements raw
open,stat, andreadsyscalls. - Avoids standard library functions to maintain low-level control.
Ensure you have GCC installed. Compile the code as follows:
gcc -m32 132_Baca_IonutAdelin_0.s -o 132_Baca_IonutAdelin_0Each operation is specified with its ID:
1: ADD2: GET3: DELETE4: DEFRAGMENTATION5: CONCRETE (bidimensional only)
5 # Number of actions
5 # Concrete action ID
/path/to/files # Concrete argument
1 # Add action ID
2 # Number of files to add
101 # First file descriptor
32 # First file dimension
102 # Second file descriptor
64 # Second file dimension
2 # Get action ID
101 # File descriptor to get
3 # Delete action ID
101 # File descriptor to delete
4 # Defragmentation action ID