Lightweight OS core for coordinating medical-care robots with safe concurrency.
This repository is scoped to the three mandatory components in Project B:
- Task queue
- Zone access control
- Health monitor
The implementation prioritizes correctness and clarity over performance, consistent with project rules.
This repository is aligned with:
Project-B.pdfproject_B_guidelines.mdAGENTS.md
Implemented mandatory behaviors:
- Multiple robots concurrently request and consume tasks.
- Zone access is mutually exclusive (no two robots in the same zone simultaneously).
- Heartbeat timeout detection marks robots offline.
Explicit non-goals:
- No preemption
- No deadlock prevention algorithms
- No complex scheduling policies
src/task_queue.rsTaskQueue:Mutex<VecDeque<Task>>+Condvar- Supports non-blocking and blocking task fetch
- Provides queue shutdown behavior (
close)
src/zones.rsZoneAccess:Mutex<HashMap<ZoneId, RobotId>>+Condvar- Enforces single-owner occupancy per zone
src/health_monitor.rsHealthMonitor:Mutex<HealthState>- Tracks
last_seenandofflinerobot sets
src/sim.rs- Demo runner (
run_demo) - Benchmark runner (
run_benchmark) - Stress sweep runner (
run_stress)
- Demo runner (
src/main.rs- CLI parsing and argument validation
tests/cli_demo.rs- Integration checks for grader-visible demo summary output
- A task is consumed at most once.
- A zone is occupied by at most one robot at a time.
- Offline robots are detected by heartbeat timeout.
- Shared mutable state is protected by synchronization primitives.
- Lock scopes are short, with no nested lock cycles in core logic.
Required project gates:
cargo build --release
cargo testAdditional recommended verification:
cargo test --releasecargo run --release -- --helpUsage summary:
project_blaze(no subcommand): run demoproject_blaze bench [robots] [tasks_per_robot] [zones] [work_ms] [validate] [offline-demo]project_blaze stress [robot_sets] [task_sets] [zone_sets] [work_ms] [validate] [offline-demo]
Argument notes:
robot_sets,task_sets,zone_setsare comma-separated lists, for example1,2,4.- Use
-to keep default sets in stress mode. validateenables extra runtime safety checks in benchmark/stress output.offline-demo,--offline-demo, andofflineare equivalent flag aliases.
Defaults:
- bench:
robots=4 tasks_per_robot=25 zones=2 work_ms=5 - stress:
robots=1,2,4,8,12 tasks_per_robot=10,25,50 zones=1,2,4 work_ms=5
This section is intentionally step-by-step so graders can verify required behaviors quickly.
cargo build --release
cargo testExpected:
- Build succeeds.
- All unit and integration tests pass.
Run demo in release mode:
cargo run --releaseExpected summary fields:
DEMO SUMMARYzone_violation=falseoffline_target=1offline_target_detected=trueoffline_robots={1}
Interpretation:
- Concurrency is active (
tasks_per_robot_donevector covers all robots). - Zone exclusivity holds (
zone_violation=false). - Offline detection is deterministic for grading (
offline_target=1and detected).
For thread-by-thread logs (optional):
cargo runDebug builds print detailed queue/zone/health transitions.
Standard benchmark:
cargo run --release -- bench 4 25 2 5 validateExpected key columns:
zone_violation=falseduplicate_tasks=false
Offline benchmark:
cargo run --release -- bench 4 50 2 20 validate --offline-demoExpected:
offline_robots >= 1zone_violation=falseduplicate_tasks=false
Standard stress sweep:
cargo run --release -- stress 1,2,4 10,25 1,2 5 validateOffline stress sweep:
cargo run --release -- stress 1,2,4 10,25 1,2 5 validate --offline-demoExpected across rows:
zone_violation=falseduplicate_tasks=false- In offline mode:
offline_robots >= 1is acceptable
Important semantics:
- Demo mode uses deterministic offline target verification.
- Benchmark/stress offline mode validates timeout behavior under workloads and may mark multiple robots offline by the end of a run.
robotstasks_totaltasks_per_robot_donemax_zone_occupancy_observedzone_violationoffline_targetoffline_target_detectedoffline_robots
robots,tasks_per_robot,zones,total_tasks,elapsed_ms,throughput_tasks_per_s,avg_zone_wait_us,cpu_user_s,cpu_sys_s,max_occupancy,zone_violation,duplicate_tasks,offline_robots
Platform note:
cpu_user_sandcpu_sys_sare populated on Unix platforms.- Non-Unix builds output
NAin CPU columns.
project_blaze/
|-- Cargo.toml
|-- README.md
|-- ROADMAP.md
|-- DIAGRAMS.md
|-- project_B_guidelines.md
|-- Project-B.pdf
|-- src/
| |-- main.rs
| |-- sim.rs
| |-- task_queue.rs
| |-- zones.rs
| |-- health_monitor.rs
| |-- logging.rs
| `-- types.rs
`-- tests/
`-- cli_demo.rs
- Architecture and flow diagrams:
DIAGRAMS.md - Milestones and compliance gates:
ROADMAP.md
- Official requirements remain the source of truth (
Project-B.pdf,project_B_guidelines.md). - Simulation timings are tuned for demonstrability and reproducibility, not realism.