← Back to Portfolio

SoftRT-Scheduler - Soft Real-Time Trading System

Overview: A high-performance soft real-time trading system in C showcasing advanced OS concepts: lock-free ring buffers, POSIX threads with CPU affinity and RT scheduling, explicit state machines, deadline-based scheduling (no sleep()), structured logging, latency histograms (p50/p95/p99), and comprehensive fault injection for robustness testing.

Key Technical Achievements

Concurrency & Synchronization: Lock-free SPSC ring buffer for zero-overhead IPC, MPMC queue with mutex + condition variables for worker distribution, and configurable backpressure policies (BLOCK, DROP, SHED_OLD).

Real-Time Features: Deadline-based scheduling using a monotonic clock (no sleep()), CPU affinity support (pthread_setaffinity_np), RT scheduling with SCHED_FIFO/SCHED_RR, and sub-millisecond latency tracking with p50/p95/p99 percentiles.

Reliability & Observability: Explicit state machine (INIT -> RUNNING -> DRAINING -> SHUTDOWN), graceful shutdown (SIGINT/SIGTERM) with queue draining, structured logging with timestamps/levels/thread IDs, and fault injection (worker hangs, crashes, tick drops, queue overflow).

Configuration & Metrics: Full CLI with 15+ options, INI config file support, real-time metrics export to CSV/JSON, and a comprehensive unit test suite (16 tests).

Architecture

The system consists of three main components:

1. Feed Thread: Generates market ticks with configurable workload patterns (steady, burst, random).

2. Dispatcher Thread: Routes ticks from the lock-free queue to the worker pool.

3. Worker Pool: Processes ticks using trading strategies (Moving Average, Momentum).

Performance

Throughput: 10,000+ ticks/second (sustained).

Latency: Average < 100 microseconds.

Stability: Valgrind-clean, zero memory leaks.

Gallery

SoftRT-Scheduler Features Engine Stats Market Simulation System Architecture Diagram MPMC Ring Buffer

Technology Stack: C11, POSIX Threads, Lock-free Data Structures, CPU Affinity, Real-time Scheduling, Monotonic Clocks

Repository: github.com/MuratAitov/SoftRT-Scheduler