I have several modifying threads and some reading threads, which all access the global variable X. I want to make my synchronization policy like this:
When a thread try to modify X, it will require a lock first, and several modifying threads can have several locks required.
When a thread try to read X, it must wait until all the modifying threads drop their locks.
Is there any solution to this situation in linux pthread library? Many thanks