This video introduces the critical region problem and presents a software solution to it:
https://www.youtube.com/watch?v=eKKc0d7kzww