Two Processes,
One Engine

Concurrengine explores the architecture of simultaneous execution. Two threads of thought, two tracks of computation, running in parallel -- synchronized at critical junctures, independent everywhere else.

The Fork Point

Every concurrent system begins with a fork -- the moment a single process splits into two. From this point forward, each thread carries its own state, its own instruction pointer, its own view of the world. They share memory but never assumptions.

barrier synchronization

Both processes reach the same point. State is reconciled. The two become one, momentarily.

Mutex Locks

When two processes need the same resource, one must wait. The mutex lock is the fundamental primitive of coordination -- a binary gate that ensures only one thread passes at a time. Fairness is not guaranteed; only safety.

Message Passing

Processes communicate through channels -- typed conduits that carry data from sender to receiver. The channel is the wire between two independent minds. Blocking or buffered, the semantics define the rhythm of coordination.

join point reached

Threads converge. Results merge. The concurrent becomes sequential for one critical moment.

The Scheduler

Beneath every concurrent system lies a scheduler -- the arbiter of time slices, the allocator of CPU cycles. It decides who runs, when, and for how long. Preemptive or cooperative, the scheduler shapes the observable behavior of every concurrent program.

Deadlock

When two processes each hold a resource the other needs, neither can proceed. The system freezes. This is the pathology of concurrency -- the moment when parallelism becomes paralysis. Detection is easy; prevention requires discipline.

process termination

All threads complete. Resources released. The engine halts gracefully.

state: idle
fork() → pid_a, pid_b
threads: 2
process_a
process_b
mutex_acquire(resource_0)
lock: acquired
chan<T> :: send(data)
buffer: 3/8
thread_0
thread_1
scheduler.next() → thread_id
quantum: 10ms
DEADLOCK DETECTED
status: halted
exit(0)
processes: 0