Skip to content
Karl Malbrain edited this page Mar 14, 2014 · 5 revisions

Phase Fair Reader Writer Lock Implementation

Two latch implementations are included in each source file: A phase-fair implementation with 8 bytes per lock, and a lite version with 2 or 4 bytes per lock.

readerwriter.c uses sched_yield/SwitchToThread on latch contention. The lite manager uses 2 bytes per lock.

             read & Release  Write & release
Phase Fair:  14 ns           21 ns
Lite:        12 ns           16 ns

rwfutex.c uses linux futex calls for latch contention. The lite lock manager also implements an alternating reader/writer phase similar to the Phase Fair version, but without the writer FIFO queue. It requires 4 bytes per lock.

Phase Fair:  14 ns           30 ns
Lite         16 ns           20 ns
Clone this wiki locally