Linux
I have two functions: functionA and functionB
These two functions can be ran multithreaded, which:
- There is at most one
functionAcan be ran at a time - There may be many
functionB(s) can be ran at a time functionAandfunctionBare exclusive, i.e iffunctionAis being excuted
thenfunctionBmust wait untilfunctionAfinishes, and if there is any instance offunctionB
is being executed thenfunctionAmust wait until all instances offunctionBfinish.
Could you please show me how to implement this using pthread in Linux? I tried many ways but it seems not clear enough.
Windows
How would I accomplish the same thing in Windows using C++?
You can use boost to create a read-write lock: