Al-Qudsi: Implementing truly safe semaphores in rust
Mahmoud Al-Qudsi providesextensive details on what it takes to implement a safe semaphore typein the Rust language.
The problem is that with n > 1, there's no concept of aprivileged" owning thread and all threads that have obtained" thesemaphore do so equally. Therefore, a rust semaphore can only everprovide read-only (&T) access to an underlying resource,limiting the usefulness of such a semaphore almost to the point ofhaving no utility. As such, the only safe owning" semaphore withread-write access that can exist in the rust world would beSemaphore<()>, or one that actually owns no data and canonly be used for its side effect of limiting concurrency while thesemaphore is owned," so to speak.