Do I need a MemoryBarrier with ReaderWriterLockSlim?

It seems that the mono implementation has no calls MemoryBarrierinside the methods ReaderWriterLockSlim. Therefore, when I make any changes internally write lock, I can get the old cached values ​​in another thread that uses read lock.

Is this really possible? Should I embed MemoryBarrierbefore and after the code inside the read / write lock?

+4
source share
2 answers

Looking at (what I think) a monophonic source , Mono ReaderWriterLockSlim is implemented using Interlocked.

x86, .

+5

, , .

: # , . , # lock, , , . , , , , .

+2

All Articles