The quick answer: so we don't miss waking someone up. But, seriously,
the semaphore code is very subtle.
This semaphore implementation allows more than one process to be in the
critical section at a time (a.k.a. a counting semaphore). In order to
support those semantics, more than one wakeup may occur before a process
is pulled off the wake_q and changed to running. Because the process that
is waiting to run (in the __down() code) is responsible for pulling itself
off the wait_q, if the 2 __up()s happen before the __down() can finish,
the 2 __up()s will wakeup the same process twice. So, the __down() code
needs to protect agaist this.
-- Bob Miller Email: rem@osdl.org Open Source Development Lab Phone: 503.626.2455 Ext. 17 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/