operating system - Difference between Counting and Binary Semaphores -
what difference between counting , binary semaphore.
what have seen somewhere both can control n number of processes have requested resource. both have taken , free states.
is there restriction on how many resources binary semaphore , counting semaphore can protect?
both allow 1 process use resource @ time...
is there other difference? above mentioned properties correct?
actually, both types used synchronize access shared resource, whether entity trying access process or thread.
the difference follows:
binary semaphores binary, can have 2 values only; 1 represent process/thread in critical section(code access shared resource) , others should wait, other indicating critical section free.
on other hand, counting semaphores take more 2 values, can have value want. max value x take allows x process/threads access shared resource simultaneously.
for further information, take @ link.
http://www.chibios.org/dokuwiki/doku.php?id=chibios:articles:semaphores_mutexes
edit
max value counting semaphore can take the number of processes want allow critical section @ same time.
again, might have case want exclusion on resource, yet know resource can accessed max number of processes (say x), set counting semaphore value x.
this allow x processes access resource @ same time; yet process x+1 have wait till 1 of processes in critical section gets out.
Comments
Post a Comment