Motivation
Programs that manage shared resources must execute portions of code called critical sections in a mutually exclusive manner. A common method of protecting critical sections is to use semaphores
Code that modifies shared data usually has the following parts:
Entry Section: The code that requests permission to modify
the shared data.
Critical Section: The code that modifies the shared variable.
Exit Section: The code that releases access to the shared data.
Remainder Section: The remaining code.