# zuhaib786/operating_systems_mtl458 architecture

> Architecture diagram of the GitHub repository zuhaib786/operating_systems_mtl458, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zuhaib786/operating_systems_mtl458
- Repository: https://github.com/zuhaib786/operating_systems_mtl458

## Overview

##### Main Components Organization
a) Shell Implementation
b) Memory Allocator
c) Page Table Simulator
d) Reader-Writer Locks

##### For Each Component, Detail the Following

A. Shell Implementation (Shell.c):
- Input Parser (for cd, history, execvp commands)
- Path Handler (MTL458 path processing)
- Command Executor
- History Manager (5 most recent commands)

B. Memory Allocator (my_alloc.c):
- 4KB Memory Page (mmap)
- Free List Manager
- Allocation Interface (my_alloc, my_free)
- Heap Information System

C. Page Table Simulator (Page_Table_Simulation.c):
- Input Processor (trace file reader)
- Page Table Manager
- Frame Allocation System
- Replacement Strategy Manager (OPT, FIFO, CLOCK, LRU, RANDOM)
- Statistics Collector

D. Reader-Writer Locks (assignment_code/):
- Reader Preference Implementation
- Writer Preference Implementation
- Shared components:
- Lock Initializer
- Common Lock Structure
- Thread Management

##### Key Design Elements

- How data moves between components
- Synchronization points in the reader-writer implementation

b) Interface Points:
- System call interfaces (mmap, munmap)
- External input points (trace files, command inputs)
- Thread interaction points

c) Memory Structures:
- 8KB frame size in page table
- 4KB mmap allocation in memory allocator
- Shared memory regions in reader-writer implementation

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef input fill:#a8d1f0,stroke:#000
    classDef memory fill:#90EE90,stroke:#000
    classDef process fill:#FFE5B4,stroke:#000
    classDef sync fill:#FFB6C1,stroke:#000
    classDef main fill:#E6E6FA,stroke:#000

    %% Main Title
    Title["OS Coursework Components"]:::main

    %% Shell Implementation Section
    subgraph Shell["Shell Implementation"]
        ShellMain["Shell.c"]
        InputParser["Input Parser"]
        PathHandler["Path Handler"]
        CmdExec["Command Executor"]
        HistoryMgr["History Manager"]

        InputParser --> PathHandler
        PathHandler --> CmdExec
        CmdExec --> HistoryMgr
    end

    %% Memory Allocator Section
    subgraph MemAlloc["Memory Allocator"]
        AllocMain["my_alloc.c"]
        MemPage["4KB Memory Page"]
        FreeList["Free List Manager"]
        AllocInterface["Allocation Interface"]
        HeapInfo["Heap Information"]

        MemPage --> FreeList
        FreeList --> AllocInterface
        AllocInterface --> HeapInfo
    end

    %% Page Table Simulator Section
    subgraph PageSim["Page Table Simulator"]
        PageMain["Page_Table_Simulation.c"]
        TraceReader["Input Processor"]
        PageTableMgr["Page Table Manager"]
        FrameAlloc["Frame Allocation"]
        ReplacementStrat["Replacement Strategies"]
        Stats["Statistics Collector"]

        TraceReader --> PageTableMgr
        PageTableMgr --> FrameAlloc
        FrameAlloc --> ReplacementStrat
        ReplacementStrat --> Stats
    end

    %% Reader-Writer Locks Section
    subgraph RWLocks["Reader-Writer Locks"]
        LockHeader["rwlock.h"]
        ReaderImpl["Reader Preference"]
        WriterImpl["Writer Preference"]
        LockInit["Lock Initializer"]
        ThreadMgr["Thread Management"]

        LockHeader --> ReaderImpl
        LockHeader --> WriterImpl
        ReaderImpl --> ThreadMgr
        WriterImpl --> ThreadMgr
        LockInit --> ThreadMgr
    end

    Title --> Shell
    Title --> MemAlloc
    Title --> PageSim
    Title --> RWLocks

    %% Click Events
    click ShellMain "https://github.com/zuhaib786/Operating_Systems_MTL458/blob/main/Shell.c"
    click AllocMain "https://github.com/zuhaib786/Operating_Systems_MTL458/blob/main/my_alloc.c"
    click PageMain "https://github.com/zuhaib786/Operating_Systems_MTL458/blob/main/Page_Table_Simulation.c"
    click TraceReader "https://github.com/zuhaib786/Operating_Systems_MTL458/tree/main/Data/Assignment3"
    click LockHeader "https://github.com/zuhaib786/Operating_Systems_MTL458/blob/main/assignment_code/rwlock.h"
    click ReaderImpl "https://github.com/zuhaib786/Operating_Systems_MTL458/blob/main/assignment_code/rwlock-reader-pref.c"
    click WriterImpl "https://github.com/zuhaib786/Operating_Systems_MTL458/blob/main/assignment_code/rwlock-writer-pref.c"

    %% Legend
    subgraph Legend
        L1["Input/Output"]:::input
        L2["Memory Management"]:::memory
        L3["Processing"]:::process
        L4["Synchronization"]:::sync
    end
```
