Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mutex between reads and writes

I am using a mutex for the critical section. I have a design constraint that, 1) If 2 reads occur in 2 different thread, then critical section should be available for both. 2) If there is a write happening, then read on other thread should be blocked 3) If there is a read happening, then write on other thread should be blocked.

I dont know to do this with Createmutex, openmutex, waitforsingleobject and releasemutex apis.

like image 222
Muthukumar Palaniappan Avatar asked Mar 24 '26 20:03

Muthukumar Palaniappan


1 Answers

What you are looking for is a Reader-Writer lock. There are some implementations of it on the internet, for example this one.

like image 148
Pierre Bourdon Avatar answered Mar 27 '26 11:03

Pierre Bourdon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!