J
jj_online
This is not a C++ specific issue. However, I am trying to implement a
readwritelock in C++ and hence would like to get help from this
group.
a readwritelock allows shared lock among all readers and exclusive
lock for a single writer. After implemented, I realized that the
writer may suffer starvation: readers can continuously get shared lock
and hence writer will wait indefinitely. so I added a writer wait
count and prevent reader acquiring shared lock as soon as a writer is
waiting. But this has serious issue: it prevents reader reentrant: a
reader already has shared lock should be able to get shared lock
again. Without reader reentrant, a reader and a writer will deadlock.
Any advice on how to resolve this issue: a writer cannot starve and
reader can reentrant?
Thanks.
readwritelock in C++ and hence would like to get help from this
group.
a readwritelock allows shared lock among all readers and exclusive
lock for a single writer. After implemented, I realized that the
writer may suffer starvation: readers can continuously get shared lock
and hence writer will wait indefinitely. so I added a writer wait
count and prevent reader acquiring shared lock as soon as a writer is
waiting. But this has serious issue: it prevents reader reentrant: a
reader already has shared lock should be able to get shared lock
again. Without reader reentrant, a reader and a writer will deadlock.
Any advice on how to resolve this issue: a writer cannot starve and
reader can reentrant?
Thanks.