Saturday, February 20, 2021

Digest for comp.lang.c++@googlegroups.com - 12 updates in 6 topics

"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Feb 19 03:32PM -0800

On 2/19/2021 3:01 PM, Bonita Montero wrote:
 
>> There are implementations that can be starvation free.
 
> No, impossible. Readers can hold the lock as long as they
> want and starve out writers. And writers could do the same.
 
Check this out:
 
https://vorbrodt.blog/2019/02/14/read-write-mutex/
 
On older rwmutex I invented. Its simple, and is starvation free wrt
reads and writes. Here is a simple Relacy test unit:
 
__________________________________
// Chris M. Thomassons RW Mutex
 
 
//#define RL_DEBUGBREAK_ON_ASSERT
//#define RL_MSVC_OUTPUT
//#define RL_FORCE_SEQ_CST
#include <relacy/relacy_std.hpp>
#include <cstdio>
#include <cstddef>
 
 
 
 
#if ! defined (NDEBUG)
# define DBG_PRINTF(e) std::printf e
#else
# define DBG_PRINTF(e) ((void)0)

No comments: