MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / WaitTimeout

Method WaitTimeout

Kernel/src/lock.cpp:20–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20void Semaphore::WaitTimeout(long timeout){
21 __sync_fetch_and_sub(&value, 1);
22 if(value < 0){
23 thread_t* cThread = GetCPULocal()->currentThread;
24 acquireLock(&cThread->stateLock);
25 blocked.add_back(cThread);
26 if(value >= 0){
27 blocked.remove(cThread);
28 releaseLock(&cThread->stateLock);
29 return;
30 }
31 releaseLock(&cThread->stateLock);
32 Timer::SleepCurrentThread(timeout); // TODO: Find a better way to do this
33 }
34}

Callers 1

SysPollFunction · 0.80

Calls 4

GetCPULocalFunction · 0.85
SleepCurrentThreadFunction · 0.85
add_backMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected