synchronization - Zero permit semaphores? -
i'm trying utilize first response this question help me on assignment i'm working on. how semaphore 0 permits work? doesn't seem create much sense me. create eternal wait @ semaphore? if that's case, how can ever have thread 'get past' semaphore while it's waiting permit never given it?
again little book of semaphores, §2.2:
listing 2.1: semaphore initialization syntaxfred = semaphore(1)
the function semaphore
constructor; creates , returns new semaphore. the initial value of semaphore passed parameter constructor.
so in author's pseduocode, 0
isn't number of permits; it's initial value of semaphore. value of 0 mean? it's explained in text proceeding listing 2.1:
if value positive, represents number of threads can decrement without blocking. if negative, represents number of threads have blocked , waiting. if value zero, means there no threads waiting, if thread tries decrement, block.
(emphases added)
synchronization semaphore
No comments:
Post a Comment