What is Semaphore

What is Semaphore

Semaphores are often used to restrict the number of threads than can access some (physical or logical) resource.

Semaphores are devices used to help with synchronization. If multiple processes share a common resource, they need a way to be able to use that resource without disrupting each other. You want each process to be able to read from and write to that resource uninterrupted.

A semaphore will either allow or disallow access to the resource, depending on how it is set up. One example setup would be a semaphore which allowed any number of processes to read from the resource, but only one could ever be in the process of writing to that resource at a time.

Leave a Reply

Your email address will not be published. Required fields are marked *