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

Method Wait

Kernel/src/lock.cpp:8–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include <logging.h>
7
8void 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
20void Semaphore::WaitTimeout(long timeout){
21 __sync_fetch_and_sub(&value, 1);

Callers 11

mainFunction · 0.45
SysPollFunction · 0.45
SysKernelObjectWaitOneFunction · 0.45
SysKernelObjectWaitFunction · 0.45
CallMethod · 0.45
WriteMethod · 0.45
AcquireBufferMethod · 0.45
ReadDiskBlockMethod · 0.45
WriteDiskBlockMethod · 0.45
ConnectToMethod · 0.45
ReceiveFromMethod · 0.45

Calls 3

GetCPULocalFunction · 0.85
CheckInterruptsFunction · 0.85
BlockCurrentThreadFunction · 0.85

Tested by

no test coverage detected