Fairness
tbu- opened this issue · 2 comments
Interesting project, got here from Reddit.
Some questions after reading the README:
- Is the mutex fair or eventually fair, i.e. does it guarantee that no thread can permanently starve another?
- What are the disadvantages and advantages compared to
parking_lot
? Quickly skimming the README ofparking_lot
suggests that their synchronization structures are also ≤ 1 word large, but even that information would be interesting in the README IMO.
-
No, it relies on the OS scheduler for fairness but tries to wake up threads in FIFO order to imply less unfair scheduling. See here for more. It looks like
docs.rs
isn't working atm and i'm not sure why. -
Advantages and disadvantages are listed in the README. It also does no heap allocations for the global table unlike in parking_lot (meaning it can be used in
#[global_allocator]
or whatever the lang attribute was). Run the benchmarks or use it locally to decide practical advantage.
Thanks for the answers.
I'm not that familiar with synchronization primitives and also wouldn't know how to benchmark them, but I understand the #[global_allocator]
use case.