# g-uooo/sc-during architecture

> Architecture diagram of the GitHub repository g-uooo/sc-during, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/g-uooo/sc-during
- Repository: https://github.com/g-uooo/sc-during

## Overview

##### Project type and purpose
- This is sc‑during: a C++ library for parallel programming on top of SystemC.
- It is not a full‑stack application but an open‑source library with example apps and tests.
- Purpose: provide “during” semantics—loosely timed parallel tasks, thread pools, event queues—on any unmodified SystemC.

##### File structure
- Top‑level:
- CMakeLists.txt, .gitlab‑ci.yml, installation scripts
- README.rst, COPYING, Doxyfile.in → build & doc tooling
- lib‑during/:
- Core modules: during-env, during-ondemand, during-pool, during-seq, during-thread, sync-task, task-manager, thread-pool‑base/ondemand
- Header files defining public API (during.h, during-if.h, async-event-queue.h)
- utils/ subfolder: atomic-variable, big-lock, cpu-affinity, io-lock, randomize, measure-time, etc.
- Examples/: sample SystemC models exercising library features
- Test/: automated test cases driven by test.sh and CMake AddSCExecTest
- install‑boost.sh, install‑doc.sh

##### README for additional insights
- Library runs on top of any SystemC implementation
- Documentation generated via Doxygen
- Test harness invokes each example in multiple modes, compares output
- Encourages writing self‑checking tests and inserting sleeps to expose races

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Dependencies
    SystemC["SystemC Kernel"]:::external
    OSThreads["OS Threads (POSIX)"]:::external

    %% Public API
    subgraph "Public API"
        direction TB
        DuringH["during.h"]:::core
        DuringIF["during-if.h"]:::core
        AsyncEQ["async-event-queue.h"]:::core
    end

    %% Core Modules
    subgraph "Core Modules"
        direction TB
        Env["during-env"]:::core
        SyncTask["sync-task"]:::core
        TaskMgr["task-manager"]:::core
        AsyncQueue["async-event-queue"]:::core

        subgraph "Scheduling Policies"
            direction TB
            Ondemand["during-ondemand"]:::core
            Seq["during-seq"]:::core
            Pool["during-pool"]:::core
            ThreadImpl["during-thread"]:::core
        end

        subgraph "Thread Pool Layer"
            direction TB
            TPBase["thread-pool-base"]:::core
            TPOnDemand["thread-pool-ondemand"]:::core
            ThreadPool["thread-pool"]:::core
            ThreadQueue["thread-queue"]:::core
        end
    end

    %% Utilities
    subgraph "Utilities"
        direction TB
        AtomicVar["atomic-variable"]:::util
        BigLock["big-lock"]:::util
        CPUAffinity["cpu-affinity"]:::util
        IOLock["io-lock"]:::util
        LockMaybe["lock-maybe"]:::util
        MeasureTime["measure-time"]:::util
        MutexWrap["mutex-wrapper"]:::util
        Randomize["randomize"]:::util
        SetInstances["set-instances"]:::util
        TestAssert["test-assert"]:::util
    end

    %% Consumers
    subgraph "Consumers"
        direction TB
        Examples["Example Applications"]:::consumers
        Tests["Test Harness"]:::consumers
    end

    %% Build & Documentation Tools
    subgraph "Build & Documentation"
        direction TB
        CMake["Top-level CMakeLists.txt"]:::tools
        GitLabCI[".gitlab-ci.yml"]:::tools
        Doxyfile["DOXYFILE.in"]:::tools
        InstallBoost["install-boost.sh"]:::tools
        InstallDoc["install-doc.sh"]:::tools
        README["README.rst"]:::tools
        COPYING["COPYING"]:::tools
    end

    %% Relationships
    SystemC -->|"wraps"| Env
    OSThreads -->|"used by"| ThreadPool
    DuringH -->|exposes API| Env
    DuringH -->|exposes API| SyncTask
    DuringH -->|exposes API| TaskMgr
    DuringIF -->|extension point| Ondemand
    DuringIF -->|extension point| Seq
    DuringIF -->|extension point| Pool
    DuringIF -->|extension point| ThreadImpl
    AsyncEQ -->|defines queue| AsyncQueue

    Env -->|"manages tasks"| SyncTask
    SyncTask -->|"registers tasks"| TaskMgr
    TaskMgr -->|"pull tasks"| AsyncQueue
    AsyncQueue -->|"enqueue tasks"| Ondemand
    AsyncQueue -->|"enqueue tasks"| Seq
    AsyncQueue -->|"enqueue tasks"| Pool
    AsyncQueue -->|"enqueue tasks"| ThreadImpl

    Ondemand -->|"strategy"| TPOnDemand
    Pool -->|"strategy"| ThreadPool
    ThreadImpl -->|"strategy"| ThreadPool

    TPBase -->|"base for"| TPOnDemand
    ThreadPool -->|"uses"| ThreadQueue

    %% Utilities usage
    AtomicVar -->|used by| Env
    BigLock -->|used by| ThreadPool
    CPUAffinity -->|used by| ThreadPool
    IOLock -->|used by| ThreadPool
    LockMaybe -->|used by| ThreadPool
    MeasureTime -->|used by| Env
    MutexWrap -->|used by| TaskMgr
    Randomize -->|used by| Env
    SetInstances -->|used by| Tests
    TestAssert -->|used by| Tests

    %% Consumers linking
    Examples -->|"link against API"| DuringH
    Examples -->|"invoke API"| Env
    Tests -->|"link against API"| DuringH
    Tests -->|"run harness"| AsyncQueue

    %% Build & Doc orchestration
    CMake -->|"build targets"| DuringH
    CMake -->|"build targets"| Examples
    CMake -->|"build targets"| Tests
    CMake -->|"build docs"| Doxyfile
    GitLabCI -->|"CI pipeline"| CMake
    InstallBoost -->|"setup dependency"| SystemC
    InstallDoc -->|"generate docs"| Doxyfile
    README -->|"documentation"| Env
    COPYING -->|"license"| Env

    %% Click Events
    click DuringH "https://github.com/g-uooo/sc-during/blob/master/lib-during/during.h"
    click DuringIF "https://github.com/g-uooo/sc-during/blob/master/lib-during/during-if.h"
    click AsyncEQ "https://github.com/g-uooo/sc-during/blob/master/lib-during/async-event-queue.h"
    click Env "https://github.com/g-uooo/sc-during/blob/master/lib-during/during-env.h"
    click Env "https://github.com/g-uooo/sc-during/blob/master/lib-during/during-env.cpp"
    click SyncTask "https://github.com/g-uooo/sc-during/blob/master/lib-during/sync-task.h"
    click SyncTask "https://github.com/g-uooo/sc-during/blob/master/lib-during/sync-task.cpp"
    click TaskMgr "https://github.com/g-uooo/sc-during/blob/master/lib-during/task-manager.h"
    click TaskMgr "https://github.com/g-uooo/sc-during/blob/master/lib-during/task-manager.cpp"
    click Ondemand "https://github.com/g-uooo/sc-during/blob/master/lib-during/during-ondemand.h"
    click Ondemand "https://github.com/g-uooo/sc-during/blob/master/lib-during/during-ondemand.cpp"
    click Seq "https://github.com/g-uooo/sc-during/blob/master/lib-during/during-seq.h"
    click Seq "https://github.com/g-uooo/sc-during/blob/master/lib-during/during-seq.cpp"
    click Pool "https://github.com/g-uooo/sc-during/blob/master/lib-during/during-pool.h"
    click Pool "https://github.com/g-uooo/sc-during/blob/master/lib-during/during-pool.cpp"
    click ThreadImpl "https://github.com/g-uooo/sc-during/blob/master/lib-during/during-thread.h"
    click ThreadImpl "https://github.com/g-uooo/sc-during/blob/master/lib-during/during-thread.cpp"
    click TPBase "https://github.com/g-uooo/sc-during/blob/master/lib-during/thread-pool-base.h"
    click TPBase "https://github.com/g-uooo/sc-during/blob/master/lib-during/thread-pool-base.cpp"
    click TPOnDemand "https://github.com/g-uooo/sc-during/blob/master/lib-during/thread-pool-ondemand.h"
    click TPOnDemand "https://github.com/g-uooo/sc-during/blob/master/lib-during/thread-pool-ondemand.cpp"
    click ThreadPool "https://github.com/g-uooo/sc-during/blob/master/lib-during/thread-pool.h"
    click ThreadPool "https://github.com/g-uooo/sc-during/blob/master/lib-during/thread-pool.cpp"
    click ThreadQueue "https://github.com/g-uooo/sc-during/blob/master/lib-during/thread-queue.h"
    click Examples "https://github.com/g-uooo/sc-during/blob/master/Examples/CMakeLists.txt"
    click Tests "https://github.com/g-uooo/sc-during/blob/master/Test/CMakeLists.txt"

    classDef core fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef util fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px
    classDef tools fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef consumers fill:#DDA0DD,stroke:#000,stroke-width:1px
```
