Readers-writers problem, pthread, mutex, unix, C++