12 readers are reading means each reader has incremented the value of ar, making final value of ar to be 12.
Also each of the reader has executed grantread in which rr is incremented to the value of ar making value of rr to be 12 finally.
31 writers are waiting means each writer on arrival has incremented the value of aw, making final value of aw to be 31.
Value of rw is incremented in grantwrite only when value of rr is 0 but as 12 readers are already reading, this cannot happen, making value of rw to be 0.
Whenever read is granted in grantread, it means value of reading semaphore is incremented to number of reader process using V(reading). But before entering the read section, each reader decrements the reading semaphore by 1 using P(reading). The fact that 12 readers are reading means that 12 V(reading) operations were performed and the 12 reader processes before entering read section have performed P(reading) each to decrement the value of reading semaphore to 0 again.
Since 12 readers are already reading, value of rr is non-zero because of which V(writing) is not executed leaving the value of writing semaphore to be 0.
------------------------------------------------------------------------------------
NO, group of readers will not starve writers as readers execute V(reading) in grantread only when aw is 0 i.e. no writer is waiting allowing writer to execute first.
YES, writers can starve readers as writers execute V(writing) without caring about readers (ar).
-------------------------------------------------------------------------------------
The solution is incorrect because:
In reader-writer problem, only single process needs to write at a time.
But in proposed solution, consider the case: When one process is writing and another write process arrives then it is also granted write using V(writing) without caring about the first process which is still writing.