Semaphore: It is a software or hardware flag.
In case of multitasking systems, a semaphore is a variable with a value which points out the status of a common resource.
It is employed to lock the resource which is being employed.
The process requiring the resource checks the semaphore to find out the resource's status and then makes a decision how to continue.