homework 5 Version 0 |
|
👤 Author: by 1529775928qqcom 2018-11-04 14:36:19 |
Semaphore is a synchronization tool to overcome the difficulty for applications programmers to use the various hard-ware solutions to the critical-section problem.
A semaphore S is an integer variable that,apart from initialization,is accessed only through two standard atomic operations:wait() and signal().Counting semaphores can be used to control access to a given resource consisting of a finite number of instances.
The semaphore is initialized to the number of resources available.Each process that wishes to use a resource performs a wait() operation on the semaphore,the count will be decremented.When a process releases a resource,it performes a signal() operation,and the count will be incremented.When the count for the semaphore goes to 0,all resources are being used.After that,processes that wish to use a resource will block until the count becomes greater than 0.