How to resolve the critical section problem in concurrent programming?