Meaning – The term semaphore, refers to an indicator used to control access to a file; for example, in a multiuser application, a flag that prevents simultaneous access to a file.
It also refers to an entity used to control access to system resources. Processes can be locked to a resource with semaphores if the processes follow certain programming conventions.
A trivial semaphore is a plain variable that is changed (for example, incremented or decremented, or toggled) depending on programmer-defined conditions.
A useful way to think of a semaphore is used in a real-world system is as a record of how many units of a particular resource are available, coupled with operations to adjust that record safely as units are acquired or become free, and, if necessary, wait until a unit of the resource becomes available.