| 6 | #include <logging.h> |
| 7 | |
| 8 | void Semaphore::Wait(){ |
| 9 | thread_t* thread = GetCPULocal()->currentThread; |
| 10 | |
| 11 | __sync_fetch_and_sub(&value, 1); |
| 12 | while(value < 0 && thread->state != ThreadStateZombie) { |
| 13 | assert(CheckInterrupts()); |
| 14 | |
| 15 | Scheduler::BlockCurrentThread(blocked, blockedLock); |
| 16 | asm("pause"); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | void Semaphore::WaitTimeout(long timeout){ |
| 21 | __sync_fetch_and_sub(&value, 1); |
no test coverage detected