# thomyluca/sistemas-operativos-1c2024 architecture

> Architecture diagram of the GitHub repository thomyluca/sistemas-operativos-1c2024, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thomyluca/sistemas-operativos-1c2024
- Repository: https://github.com/thomyluca/sistemas-operativos-1c2024

## Overview

- Kernel
- Memoria (Memory)
- Cpu
- Entrada/Salida (I/O, handling devices like keyboard, monitor, file system, etc.)

The README details specific aspects such as multiple scheduling algorithms in the Kernel, a paging algorithm and TLB replacement strategies in Memoria, and a File System that can perform compaction. The file tree confirms that each module is self-contained with its own configuration files, headers, source code, and even testing scripts. There is also a shared “utils” directory that likely contains common functionalities for inter-module communications via sockets and other helper routines.

##### Functional Layers Within Each Module
- For Memoria, illustrate the memory management component, highlighting the paging algorithm and a separate TLB component (with FIFO and LRU replacement policies).
- For Cpu, mark the core execution logic and associated components (like instruction processing and communications interfaces).
- For Entrada/Salida, mark the various functionalities: keyboard, monitor, file systems (including aspects such as compaction), and other I/O components.

##### Relationships & Data Flows
- Bidirectional communication between Cpu and Memoria if such interactions exist (e.g., for fetching instructions or handling memory references).
- Similarly, show communication between Entrada/Salida and Kernel for I/O completions or interrupts.
- Optionally, show the shared “utils” layer as providing support to all these modules (e.g., through standardized communication protocols – the “sockets” related files suggest a network/socket-based architecture).

##### Architectural Patterns and Design Principles
- Separation of concerns across modules: each module’s own directory shows a clear division focused on its role.
- The use of configuration files (each module has a set of configs) indicates that the system is designed for flexibility in testing different scenarios (e.g., “Dead”, “Edge”, “Entrada”, “FS”, “Memo”, “Plani” configurations).
- Modular design that accommodates testing scripts separately (as seen in the “scripts” and “scripts-pruebas” directories), which is important for simulation testing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Kernel Module Subgraph
    subgraph "Kernel Module"
        Kernel["Kernel"]:::kernelStyle
        K_Scheduler["Scheduler (FIFO,RR,VRR)"]:::kernelStyle
        K_Console["Console Interface"]:::kernelStyle
        Kernel --> K_Scheduler
        Kernel --> K_Console
    end

    %% Memoria Module Subgraph
    subgraph "Memoria Module"
        Memoria["Memoria"]:::memoriaStyle
        M_MemoryManager["Memory Manager (Paging)"]:::memoriaStyle
        M_TLB["TLB (FIFO/LRU)"]:::memoriaStyle
        Memoria --> M_MemoryManager
        Memoria --> M_TLB
    end

    %% Cpu Module Subgraph
    subgraph "Cpu Module"
        Cpu["Cpu"]:::cpuStyle
        Cpu_Core["Core Execution & Instructions"]:::cpuStyle
        Cpu_Comm["Communication Interface"]:::cpuStyle
        Cpu --> Cpu_Core
        Cpu --> Cpu_Comm
    end

    %% Entrada/Salida Module Subgraph
    subgraph "Entrada/Salida Module"
        Entradasalida["Entrada/Salida"]:::ioStyle
        IO_Keyboard["Keyboard"]:::ioStyle
        IO_Monitor["Monitor"]:::ioStyle
        IO_FileSystem["File System (Compaction)"]:::ioStyle
        Entradasalida --> IO_Keyboard
        Entradasalida --> IO_Monitor
        Entradasalida --> IO_FileSystem
    end

    %% Shared Utilities Subgraph
    subgraph "Shared Utilities"
        Utils["utils"]:::utilsStyle
        Socket_Client["Socket Client"]:::utilsStyle
        Socket_Util["Socket Utils"]:::utilsStyle
        Utils --> Socket_Client
        Utils --> Socket_Util
    end

    %% Inter-module Communication Connections
    %% Kernel Scheduler dispatches operations
    K_Scheduler -->|"dispatch"| Cpu_Core
    K_Scheduler -->|"memoryReq"| M_MemoryManager
    K_Scheduler -->|"ioOps"| IO_FileSystem

    %% Bidirectional communication between Cpu and Memoria
    Cpu_Core <-->|"memAccess"| M_MemoryManager

    %% I/O module signals interrupt/completion to Kernel Console
    IO_FileSystem -->|"interrupt"| K_Console

    %% All modules leverage shared utilities (dashed lines for common support)
    K_Console --- Utils
    M_TLB --- Utils
    Cpu_Comm --- Utils
    IO_Monitor --- Utils

    %% Click Events for Main Modules
    click Kernel "https://github.com/thomyluca/sistemas-operativos-1c2024/tree/main/kernel/"
    click Memoria "https://github.com/thomyluca/sistemas-operativos-1c2024/tree/main/memoria/"
    click Cpu "https://github.com/thomyluca/sistemas-operativos-1c2024/tree/main/cpu/"
    click Entradasalida "https://github.com/thomyluca/sistemas-operativos-1c2024/tree/main/entradasalida/"
    click Utils "https://github.com/thomyluca/sistemas-operativos-1c2024/tree/main/utils/"

    %% Click Events for Kernel Subcomponents
    click K_Scheduler "https://github.com/thomyluca/sistemas-operativos-1c2024/blob/main/kernel/src/planificador.c"
    click K_Console "https://github.com/thomyluca/sistemas-operativos-1c2024/blob/main/kernel/include/consola.h"

    %% Click Events for Memoria Subcomponents
    click M_MemoryManager "https://github.com/thomyluca/sistemas-operativos-1c2024/blob/main/memoria/src/manejo_memoria.c"
    click M_TLB "https://github.com/thomyluca/sistemas-operativos-1c2024/tree/main/memoria/scripts-pruebas/script_tlb_fifo"

    %% Click Events for Cpu Subcomponents
    click Cpu_Core "https://github.com/thomyluca/sistemas-operativos-1c2024/blob/main/cpu/src/instrucciones.c"
    click Cpu_Comm "https://github.com/thomyluca/sistemas-operativos-1c2024/blob/main/cpu/src/tlb.c"

    %% Click Events for Entrada/Salida Subcomponents
    click IO_FileSystem "https://github.com/thomyluca/sistemas-operativos-1c2024/blob/main/entradasalida/include/dialfs.h"
    click IO_Keyboard "https://github.com/thomyluca/sistemas-operativos-1c2024/blob/main/entradasalida/src/comunicaciones.c"

    %% Click Events for Shared Utilities Subcomponents
    click Socket_Client "https://github.com/thomyluca/sistemas-operativos-1c2024/blob/main/utils/include/sockets_client.h"
    click Socket_Util "https://github.com/thomyluca/sistemas-operativos-1c2024/blob/main/utils/src/utils/sockets_utils.c"

    %% Styles
    classDef kernelStyle fill:#F39C12,stroke:#333,stroke-width:2px;
    classDef memoriaStyle fill:#27AE60,stroke:#333,stroke-width:2px;
    classDef cpuStyle fill:#2980B9,stroke:#333,stroke-width:2px;
    classDef ioStyle fill:#8E44AD,stroke:#333,stroke-width:2px;
    classDef utilsStyle fill:#34495E,stroke:#333,stroke-width:2px;
```
