Skip to content

ModernityRejecter/Contiguous-Memory-Allocation-Sim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contiguous Memory Allocation Simulator (x86 Assembly)

This repository contains an x86 (32-bit) assembly implementation of a contiguous memory allocation system. It simulates how an operating system manages memory blocks or how a file system allocates space on a disk.

Project Overview

The simulator models a memory space (8MB total) divided into blocks of 8KB. For the purpose of this simulation, the logic is scaled down to 1024 addressable units. The project consists of two main tasks:

  • Task 1: Unidimensional Memory Allocation Simulates a 1D memory array where files are allocated contiguously using a First-Fit strategy.
  • Task 2: Bidimensional Memory Allocation Extends the simulation to a 2D memory grid (matrix). Note: The CONCRETE operation is not implemented in this version.

Supported Operations

The simulator supports the following commands:

  • ADD (1): Allocate a contiguous range of blocks for a file.
  • GET (2): Retrieve the start and end indices of a file.
  • DELETE (3): Free all blocks associated with a specific file.
  • DEFRAGMENTATION (4): Reorganize memory to eliminate external fragmentation by moving all allocated files to the beginning of the memory space.
  • CONCRETE (5 - Task 2 only): Not implemented.

Repository Structure

  • src/: Contains the x86 assembly source code (task1.s, task2.s).
  • tests/: Input and expected output files for automated testing.
  • scripts/: Python scripts for testing (checker.py) and generating test cases (generator.py).
  • docs/: Original project requirements in Romanian (PDF).
  • Makefile: Build instructions for compiling the assembly code.

Getting Started

Prerequisites

To build and run this project, you need:

  • A Linux environment (or WSL on Windows).
  • gcc with 32-bit support (gcc-multilib).
  • make and python3.

Building the Project

Run the following command in the root directory:

make

This will generate two executables: task1 and task2.

Running Tests

You can use the provided checker script to verify the implementation:

python3 scripts/checker.py

Technical Details

  • Language: x86 Assembly (32-bit, AT&T Syntax).
  • System Calls: Uses Linux system calls for I/O and file management.
  • Memory Strategy: First-Fit for contiguous allocation.

License

This project was developed as part of the Computer Systems Architecture (ASC) course at the University of Bucharest, 2024-2025.

About

A contiguous memory allocator simulator fully written in x_86 32 bit assembly, offers a linear memory configuration and a matrix memory configuration. Both configurations have implementations for 4 functions, ADD, GET, DELETE and DEFRAG which are used to read, write, delete and remove external fragmentation respectively.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors