Skip to content

feat: Implement Lab 6 - Real-Time Mobile Robot System Simulation#8

Merged
Veexeq merged 17 commits into
mainfrom
lab6
May 23, 2026
Merged

feat: Implement Lab 6 - Real-Time Mobile Robot System Simulation#8
Veexeq merged 17 commits into
mainfrom
lab6

Conversation

@Veexeq
Copy link
Copy Markdown
Owner

@Veexeq Veexeq commented May 23, 2026

Description

This PR introduces the complete solution for Lab 6 (Operating Systems). It implements a highly concurrent, multi-threaded simulation of a mobile robot's internal operating system, scaling from basic synchronization to Real-Time Operating System (RTOS) concepts.

Key Changes & Features

The project was developed iteratively across three levels, adhering strictly to the DRY (Don't Repeat Yourself) principle using a shared common library.

  • Architecture & Build System:

    • Implemented a structured project layout (src/, include/, obj/, bin/, output/, scripts/).
    • Added a dynamic Makefile for compiling specific simulation levels (make level1, make level2, make level3).
    • Added .gitignore to keep the repository clean from binaries and generated logs.
  • Level 1 (program1.c): Basic Synchronization

    • Created 6 independent threads (Cameras, Synchronizer, Image Writer, Robot State, Logger) running at different frequencies (10Hz - 100Hz).
    • Used pthread_mutex_t and sem_t to prevent race conditions.
  • Level 2 (program2.c): Advanced IPC & Graceful Shutdown

    • Implemented a 64-element Circular Buffer (FIFO) for lossless frame handling.
    • Replaced busy-waiting with Condition Variables (pthread_cond_t) for microsecond-level thread wake-ups.
    • Added robust SIGINT (CTRL+C) interception for graceful shutdown and memory cleanup.
  • Level 3 (program3.c): RTOS & Lock-Free Monitoring

    • Applied Real-Time Scheduling (SCHED_FIFO) granting hardware-level priority to the robot state and camera threads.
    • Introduced a Watchdog Thread to monitor deadline misses.
    • Replaced standard mutex-based counters with C11 Atomics (stdatomic.h) for lock-free performance monitoring.
  • Automated Testing:

    • Added bash scripts (scripts/run_levelX.sh) to automatically compile, run, simulate SIGINT, and analyze outputs.

How to Test

  1. Pull the branch and navigate to the root directory.
  2. Ensure scripts have execution permissions: chmod +x scripts/*.sh
  3. Run the automated tests:
   ./scripts/run_level1.sh
   ./scripts/run_level2.sh
   sudo ./scripts/run_level3.sh # 'sudo' is required to grant SCHED_FIFO real-time priorities
  1. Verify that the output/ directory contains simulated .jpg files and the robot_state.txt log without memory leaks or race conditions.

Checklist:

  • Code compiles without warnings (-Wall -Wextra)
  • No busy-waiting utilized
  • Graceful shutdown handles pthread_join and resource destruction
  • README.md updated with project documentation

@Veexeq Veexeq self-assigned this May 23, 2026
@Veexeq Veexeq merged commit ca67711 into main May 23, 2026
1 check passed
@Veexeq Veexeq deleted the lab6 branch May 23, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant