Problem 2
Here we retain the requirement that writers must have exclusive access while readers may share, but we add the requirement that once a writer is ready to write, he performs his "write" as soon as possible. A solution
to this problem cannot be a solution to Problem 1 because to meet this requirement a reader who arrives
after a writer has announced that he is ready to write must wait even if the writer is also waiting. For the first problem it was possible that a writer could wait indefinitely while a stream of readers arrived. In this problem we give priority to writers and allow readers to wait indefinitely while a stream of writers is working.
On general principles we require that the solution give priority to writers without making any assumptions about priority being built into the V routine. In other words, where several processes are waiting at a semaphore, we cannot predict which one will be allowed to proceed as the result of a V operation.