Should we do the checking of state of a shared resource atomically?
I want to know whether we should do the checking of the state of a shared-resource atomically or no. e.g. Consider the following code which demonstrates the classic Bounded-Buffer problem;