# shahriar-0/operating-system-course-projects-f2023 architecture

> Architecture diagram of the GitHub repository shahriar-0/operating-system-course-projects-f2023, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shahriar-0/operating-system-course-projects-f2023
- Repository: https://github.com/shahriar-0/operating-system-course-projects-f2023

## Overview

This repository is structured around three separate operating system projects for a course, each implementing a distinct system-level concept:

##### CA1: Socket Programming
- Purpose: A customer-restaurant-supplier application using TCP sockets and UDP broadcasts for messaging.
- Main components:
– Multiple process types: customer, restaurant, supplier
– Network components: TCP socket communication (for internal messaging) and UDP for broadcasts
– Logging subsystem: Each process logs into its own file
- Relevant files:
– All code under "P1 - Socket Programming/Code" (contains source code and supporting makefiles)
– "Assets" include examples, descriptions, slides, and recipes for testing/understanding
- Architectural pattern: Process-based distributed communication using the POSIX sockets API

##### CA2: MapReduce Counter
- Purpose: Implements a MapReduce-style counter where cost values from CSV files (for various buildings’ bills) are processed concurrently.
- Main components:
– Data ingestion: Reading CSV files for multiple buildings
– Map stage: Each building creates its own process to process a part of the data
– Reduce stage: A main financial process receives data from multiple worker processes (communication via POSIX unnamed and named pipes)
– Inter-process communication: Reliance on pipes to manage distributed data processing
- Relevant files:
– All code under "P2 - Map Reduce/Code" (including Makefiles, source files, and building CSVs)
- Architectural pattern: MapReduce paradigm applied to cost counting, with process-based separation and IPC for data aggregation

##### CA3: Parallel Image Processing
- Purpose: Applies image filters to BMP24 images both serially and concurrently using POSIX threads.
- Main components:
– Image I/O: A custom Bmp class for reading/writing BMP files
– Filters: Filtering functions (e.g., vertical flip, Gaussian blur, purple haze) implemented in a designated filter namespace
– Serial processing: A version that processes the entire image in sequence
– Parallel processing: A thread pool implemented with POSIX threads, a mutex-protected task queue, and splitting the image into multiple BmpViews for concurrent processing
- Relevant files:
– Code directories under "P3 - MultiThread Image Processing/Code" (separate folders for serial and parallel implementations, build scripts, etc.)
- Architectural pattern: Parallelism using thread pools and task queues, with explicit division between serial and parallel pipelines

– One grouping for CA1 (Socket Programming)
– One grouping for CA2 (MapReduce Counter)
– One grouping for CA3 (Parallel Image Processing)

- CA1: List separate process types (customer, restaurant, supplier). Indicate that each process has its own logging component and communicates over TCP (for regular messages) and UDP (for broadcasts)
- CA2: Illustrate the Map stage (individual building processes reading CSV parts), Reduce stage (the central financial process), and show the different types of pipes connecting these processes (unnamed pipes for worker communications, named pipes for their connection to the central process)
- CA3: Show the image input component (Bmp loader), the filter engine (filter functions), the serial processing pipeline, as well as the parallel processing components including the thread pool and the task queue. Represent the division of the image into multiple BmpViews for concurrent processing

d. Incorporate architectural patterns and technology details:
- That CA1 is built using POSIX sockets with process separation and CLI-defined commands
- Use of inter-process communication (pipes) in CA2’s MapReduce model
- Use of POSIX threads and a mutex-protected task queue in CA3’s parallel image processing

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CA1: Socket Programming"
      direction TB
      CP["Customer Process"]:::process
      CL["Customer Logger"]:::logger
      RP["Restaurant Process"]:::process
      RL["Restaurant Logger"]:::logger
      SP["Supplier Process"]:::process
      SL["Supplier Logger"]:::logger
      NS["TCP Socket & UDP Broadcast"]:::network

      CP -->|"logs-to"| CL
      RP -->|"logs-to"| RL
      SP -->|"logs-to"| SL

      CP -->|"usesPOSIXsocket"| NS
      RP -->|"usesPOSIXsocket"| NS
      SP -->|"usesPOSIXsocket"| NS
    end

    subgraph "CA2: MapReduce Counter"
      direction TB
      CSV["CSV Files"]:::data
      BP["Building Process (Map Stage)"]:::map
      MP["Mapping Function"]:::map
      IPC["IPC via Pipes"]:::ipc
      FP["Financial Process (Reduce Stage)"]:::reduce
      LOG["Logger/Console Logger"]:::logger

      CSV -->|"reads"| BP
      BP -->|"mapsData"| MP
      BP -->|"usesPipes"| IPC
      IPC -->|"aggregates"| FP
      MP -->|"sendsToReduce"| FP
      FP -->|"outputsTo"| LOG
    end

    subgraph "CA3: Parallel Image Processing"
      direction TB
      IMG["BMP Image Input"]:::image
      SERIAL["Serial Pipeline"]:::pipeline
      SERIAL_PROC["Bmp Loader & Filters (Serial)"]:::serial
      PARALLEL["Parallel Pipeline"]:::pipeline
      THREADPOOL["Thread Pool & Task Queue"]:::thread
      PARALLEL_PROC["Bmp Loader & Filters (Parallel)"]:::parallel
      OUT["Output Image (output.bmp)"]:::output

      IMG -->|"loadsForSerial"| SERIAL_PROC
      SERIAL_PROC -->|"processesSerially"| SERIAL
      IMG -->|"loadsForParallel"| PARALLEL_PROC
      PARALLEL_PROC -->|"processesConcurrently"| THREADPOOL
      THREADPOOL -->|"splitsIntoBmpViews"| PARALLEL
      SERIAL -->|"writesOutput"| OUT
      PARALLEL -->|"writesOutput"| OUT
    end

    classDef process fill:#f9c,stroke:#333,stroke-width:2px;
    classDef logger fill:#ff9,stroke:#333,stroke-width:2px;
    classDef network fill:#9f9,stroke:#333,stroke-width:2px;
    classDef map fill:#9ff,stroke:#333,stroke-width:2px;
    classDef reduce fill:#fc9,stroke:#333,stroke-width:2px;
    classDef ipc fill:#cff,stroke:#333,stroke-width:2px;
    classDef data fill:#eef,stroke:#333,stroke-width:2px;
    classDef image fill:#ffc,stroke:#333,stroke-width:2px;
    classDef pipeline fill:#cfc,stroke:#333,stroke-width:2px;
    classDef serial fill:#ccf,stroke:#333,stroke-width:2px;
    classDef thread fill:#fca,stroke:#333,stroke-width:2px;
    classDef parallel fill:#acf,stroke:#333,stroke-width:2px;
    classDef output fill:#fcf,stroke:#333,stroke-width:2px;

    %% Click Events for CA1
    click CP "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P1 - Socket Programming/Code/src/customer.c"
    click CL "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P1 - Socket Programming/Code/src/logger.c"
    click RP "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P1 - Socket Programming/Code/src/restaurant.c"
    click RL "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P1 - Socket Programming/Code/src/logger.c"
    click SP "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P1 - Socket Programming/Code/src/supplier.c"
    click SL "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P1 - Socket Programming/Code/src/logger.c"
    click NS "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P1 - Socket Programming/Code/src/network.c"

    %% Click Events for CA2
    click BP "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P2 - Map Reduce/Code/src/building_process.cpp"
    click MP "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P2 - Map Reduce/Code/src/map.cpp"
    click FP "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P2 - Map Reduce/Code/src/financial_process.cpp"
    click IPC "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P2 - Map Reduce/Code/src/reduce.cpp"
    click LOG "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P2 - Map Reduce/Code/src/console_logger.hpp"

    %% Click Events for CA3 - Serial Components
    click SERIAL_PROC "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P3 - MultiThread Image Processing/Code/serial/src/bmp.cpp"
    click SERIAL_PROC "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P3 - MultiThread Image Processing/Code/serial/src/bmp.hpp"
    click SERIAL_PROC "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P3 - MultiThread Image Processing/Code/serial/src/filter.cpp"
    click SERIAL_PROC "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P3 - MultiThread Image Processing/Code/serial/src/filter.hpp"

    %% Click Events for CA3 - Parallel Components
    click THREADPOOL "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P3 - MultiThread Image Processing/Code/parallel/src/pool.cpp"
    click THREADPOOL "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P3 - MultiThread Image Processing/Code/parallel/src/pool.hpp"
    click THREADPOOL "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P3 - MultiThread Image Processing/Code/parallel/src/thread.cpp"
    click THREADPOOL "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P3 - MultiThread Image Processing/Code/parallel/src/thread.hpp"
    click THREADPOOL "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P3 - MultiThread Image Processing/Code/parallel/src/mutex.hpp"
    click PARALLEL_PROC "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P3 - MultiThread Image Processing/Code/parallel/src/bmp.cpp"
    click PARALLEL_PROC "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P3 - MultiThread Image Processing/Code/parallel/src/bmp.hpp"
    click PARALLEL_PROC "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P3 - MultiThread Image Processing/Code/parallel/src/filter.cpp"
    click PARALLEL_PROC "https://github.com/shahriar-0/operating-system-course-projects-f2023/blob/main/P3 - MultiThread Image Processing/Code/parallel/src/filter.hpp"
```
