MCPcopy Create free account
hub / github.com/cemu-project/Cemu / __OSActivateThread

Function __OSActivateThread

src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp:106–133  ·  view source on GitHub ↗

add thread to active queue

Source from the content-addressed store, hash-verified

104
105 // add thread to active queue
106 void __OSActivateThread(OSThread_t* thread)
107 {
108 cemu_assert_debug(__OSHasSchedulerLock());
109
110 g_activeThreadQueue->addThread(thread, &thread->activeThreadChain); // todo - check if thread already in queue
111
112 MPTR threadMPTR = memory_getVirtualOffsetFromPointer(thread);
113
114 srwlock_activeThreadList.LockWrite();
115 bool alreadyActive = false;
116 for (sint32 i = 0; i < activeThreadCount; i++)
117 {
118 if (activeThread[i] == threadMPTR)
119 {
120 cemu_assert_debug(false); // should not happen
121 alreadyActive = true;
122 }
123 }
124 if (alreadyActive == false)
125 {
126 activeThread[activeThreadCount] = threadMPTR;
127 activeThreadCount++;
128 }
129
130 __OSCreateHostThread(thread);
131
132 srwlock_activeThreadList.UnlockWrite();
133 }
134
135 // remove thread from active queue. Reset id and state
136 void __OSDeactivateThread(OSThread_t* thread)

Callers 2

OSRunThreadFunction · 0.85

Calls 7

cemu_assert_debugFunction · 0.85
__OSHasSchedulerLockFunction · 0.85
__OSCreateHostThreadFunction · 0.85
addThreadMethod · 0.80
LockWriteMethod · 0.45
UnlockWriteMethod · 0.45

Tested by

no test coverage detected