MCPcopy Create free account
hub / github.com/doldecomp/mkdd / __OSThreadInit

Function __OSThreadInit

libs/dolphin/os/OSThread.c:92–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92void __OSThreadInit() {
93 OSThread* thread = &DefaultThread;
94 int prio;
95
96 thread->state = OS_THREAD_STATE_RUNNING;
97 thread->attr = OS_THREAD_ATTR_DETACH;
98 thread->priority = thread->base = 16;
99 thread->suspend = 0;
100 thread->val = (void*)-1;
101 thread->mutex = NULL;
102 OSInitThreadQueue(&thread->queueJoin);
103 OSInitMutexQueue(&thread->queueMutex);
104
105 __OSFPUContext = &thread->context;
106
107 OSClearContext(&thread->context);
108 OSSetCurrentContext(&thread->context);
109 thread->stackBase = (void*)_stack_addr;
110 thread->stackEnd = (void*)_stack_end;
111 *(thread->stackEnd) = OS_THREAD_STACK_MAGIC;
112
113 OSSetCurrentThread(thread);
114 OSClearStack(0);
115
116 RunQueueBits = 0;
117 RunQueueHint = FALSE;
118 for (prio = OS_PRIORITY_MIN; prio <= OS_PRIORITY_MAX; ++prio) {
119 OSInitThreadQueue(&RunQueue[prio]);
120 }
121
122 OSInitThreadQueue(&__OSActiveThreadQueue);
123 AddTail(&__OSActiveThreadQueue, thread, linkActive);
124 OSClearContext(&IdleContext);
125 Reschedule = 0;
126}
127
128void OSInitThreadQueue(OSThreadQueue* queue) { queue->head = queue->tail = NULL; }
129

Callers 1

OSInitFunction · 0.85

Calls 4

OSInitThreadQueueFunction · 0.85
OSInitMutexQueueFunction · 0.85
OSSetCurrentThreadFunction · 0.85
OSClearStackFunction · 0.85

Tested by

no test coverage detected