Corrected bug in semaphore/lock release with yeilding