PRJ-03

Concurrent Systems

A syscall-log parser rebuilt as a concurrent pipeline, and a disk device driver synchronised through bounded queues.

Status
Coursework
Period
2025–2026

Multithreaded strace analyser

I rebuilt a sequential syscall-log parser as a concurrent pipeline, using a producer thread streaming trace lines into a bounded, condition-variable-backed work queue. Each worker was given a thread-local statistics map, merged once at join rather than contended on throughout.

The interesting part was not making it concurrent but finding where concurrency stops paying. Benchmarked against one thread, two, four, and eight on the same trace, it never started: each added thread cost time rather than saved it. Parsing a single line is short enough that the queue synchronisation around it, and the merge at join, dominate the work being handed out.

Concurrent disk device driver

Application threads synchronised against a disk device through two bounded producer-consumer queues, drained by dedicated read and write worker threads with voucher-based asynchronous completion, so callers are not blocked waiting on the device.

Note

This was assessed coursework, so no source code is published. The design and the results are discussed here instead.

02004006001248Worker threadsExecution time (ms)167 ms489 ms
Fig. 1 — Wall-clock time for the same trace against worker-thread count, three runs at each count with the medians joined. Time rises at every step — 167 ms on one thread to 489 ms on eight — so on this input the queue and merge overhead outweighs the parsing the extra threads take on.
Application threadsDisk driverBounded write queueBounded read queueWrite worker threadRead worker threadDisk deviceread / write requestvoucherenqueuedescriptor + voucherdequeuesector read / writestatusresult via voucherresult via voucher
Fig. 2 — The driver's shape. An application thread hands a read or a write to the driver and is given a voucher rather than made to wait: the request sits in one of two bounded queues until the worker thread that owns that direction drains it against the device, and the result is published on the voucher for the caller to redeem. Vouchers and sector descriptors come from bounded pools rather than being allocated per request. Drawn from the submitted collaboration diagrams, with the call sequence dropped.