Reader starvation
Reader starvation
Version 2 gives rise to reader starvation if there is always a writer waiting
ie. [waitingW > 0].
The solution to reader starvation is to make readers defer to make a writer give preference to readers when it finishes accessing the shared resource.
To do this, we introduce a boolean readersturn which is set by releaseWrite() and cleared by releaseRead()