pseudo-c code of readers-writer problem