MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / SelectThread

Function SelectThread

src/dolphin/src/os/OSThread.c:263–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263static OSThread* SelectThread(BOOL yield)
264{
265 OSContext* currentContext;
266 OSThread* currentThread;
267 OSThread* nextThread;
268 OSPriority priority;
269 OSThreadQueue* queue;
270
271 if (0 < Reschedule)
272 {
273 return 0;
274 }
275
276 currentContext = OSGetCurrentContext();
277 currentThread = OSGetCurrentThread();
278 if (currentContext != &currentThread->context)
279 {
280 return 0;
281 }
282
283 if (currentThread)
284 {
285 if (currentThread->state == OS_THREAD_STATE_RUNNING)
286 {
287 if (!yield)
288 {
289 priority = __cntlzw(RunQueueBits);
290 if (currentThread->priority <= priority)
291 {
292 return 0;
293 }
294 }
295 currentThread->state = OS_THREAD_STATE_READY;
296 SetRun(currentThread);
297 }
298
299 if (!(currentThread->context.state & OS_CONTEXT_STATE_EXC) &&
300 OSSaveContext(&currentThread->context))
301 {
302 return 0;
303 }
304 }
305
306 if (RunQueueBits == 0)
307 {
308 SwitchThreadCallback(__OSCurrentThread, NULL);
309 __OSCurrentThread = NULL;
310 OSSetCurrentContext(&IdleContext);
311 do
312 {
313 OSEnableInterrupts();
314 while (RunQueueBits == 0)
315 ;
316 OSDisableInterrupts();
317 } while (RunQueueBits == 0);
318
319 OSClearContext(&IdleContext);
320 }

Callers 2

__OSRescheduleFunction · 0.85
OSYieldThreadFunction · 0.85

Calls 4

OSGetCurrentThreadFunction · 0.85
SetRunFunction · 0.85
OSDisableInterruptsFunction · 0.85
__OSSwitchThreadFunction · 0.85

Tested by

no test coverage detected