When should I avoid RwLock in Linux

RwLock on some systems such as Linux, suffers from the writer starvation problem. It's a situation when readers continually access the shared resource, and writer threads never get the chance to access the shared resource. (Rahul Sharma, Vesa Kaihlavirta, et al, 2019, The Complete Rust Programming Reference Guide)

What implications does it have if Linux is my primary target? Is there any method to prevent writer starvation?

The parking_lot crate has a drop-in replacement for RwLock and others that doesn't suffer from the starvation problem.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.