remzi-arpacidusseau / ostep-typos

50 stars 44 forks source link

Semaphores - typo in Fig 31.17 Zemaphore implementation? #32

Closed ambareeshsrja16 closed 11 months ago

ambareeshsrja16 commented 3 years ago

Figure 31.17 Implementing Zemaphores with Locks and CVs: image

In function Zem_Wait, the code checks first if the value is <=0 and waits. After which it decrements the value. However from the defintions earlier (say figure 31.2):

image

sem_wait is supposed to decrement the value first and then wait if the value is negative. Is this a typo or am I missing something here?

remzi-arpacidusseau commented 11 months ago

As the text (kind of) explains, this impl is a little different than the pure sema definition...