"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Feb 20 12:46PM -0800 On 2/19/2021 11:50 PM, Bonita Montero wrote: >> Ummm... I am not sure what you mean here. ... > Readers can hold the mutex as long as they want. > And writers can do the opposite. Indeed. But you snipped my relevant part. > So they can prevent other writers or readers to lock the mutex. > So RW-locks are never starvation-free. Let me manually quote what I wrote. Its important because the type of starvation your are talking about is very different than the usual meaning. Chris M. Thomasson wrote: _________________________________ [...] The type of starvation I am talking about is when reader activity is so frequent that writers just can't seem to get in. Even if the reader critical sections are short. Every time a writer wants to get in, several readers jump in line. Its all about reader or writer priority, a lot of rwmutex impls have that flaw. Sure a reader can hold the lock for an hour, okay. Well, writers cannot get in for an hour. That's perfectly normal. This is not the same type of starvation I am referring to... _________________________________ Starvation on a rw mutex can occur when heavy reader activity actually starves out writers. Some implementations can actually prioritize reads, or writes. Some implementations have reader preference by design. So, starvation can occur when frequent readers prevent writers from acquiring write access. In other words, writers spend most of their time tying and failing to acquire the mutex. This is why its important to be very careful when one is implementing a rwmutex. I linked you to an algorithm I invented that is loop-free. It fairly alternates between batches of readers and writers. So, readers can never starve out writers, even during massive reader activity, and vise versa. |
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Feb 20 12:52PM -0800 On 2/20/2021 12:46 PM, Chris M. Thomasson wrote: > algorithm I invented that is loop-free. It fairly alternates between > batches of readers and writers. So, readers can never starve out > writers, even during massive reader activity, and vise versa. Heavy writer activity starving out readers can happen, but its rather unusual. General use patterns for a read write mutex is when you have read mostly workloads. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.programming.threads+unsubscribe@googlegroups.com. |
No comments:
Post a Comment