Criticla section locking algo