Difference between revisions of "ARM9 OS"
Jump to navigation
Jump to search
Hallowizer (talk | contribs) (→Threads: info on how the scheduler works) |
Hallowizer (talk | contribs) (→Threads: waitingMutex isn't part of OSMutexQueue (at least not on wii)) |
||
Line 44: | Line 44: | ||
struct OSThreadLink linkQueue; // 0x7c | struct OSThreadLink linkQueue; // 0x7c | ||
u32 unknown2; // 0x80 | u32 unknown2; // 0x80 | ||
− | struct OSMutexQueue | + | struct OSMutex *mutex; // 0x84 - set to the mutex the thread is currently trying to lock |
+ | struct OSMutexQueue queueMutex; // 0x88 | ||
// more unknown fields - the total length is not known | // more unknown fields - the total length is not known | ||
} | } | ||
Line 67: | Line 68: | ||
struct OSMutexQueue { | struct OSMutexQueue { | ||
− | |||
struct OSMutex *head; | struct OSMutex *head; | ||
struct OSMutex *tail; | struct OSMutex *tail; |
Revision as of 00:35, 15 July 2022
The ARM9 SDK contains an OS library that handles various functions. It does not have many debugging strings, so most names listed on this page are taken from the Wii.
Threads
The scheduler only runs the thread with the highest priority, and does not switch between threads if two threads have the same priority. Because of this, rescheduling only happens when a thread-related function is called and the thread with the highest priority can no longer run.
struct OSFpContext { f64 REG_DIV_NUMER; // 0x0 f64 REG_DIV_DENOM; // 0x8 f64 SQRT_PARAM; // 0x10 u16 REG_DIVCNT; // 0x18 u16 REG_SQRTCNT; // 0x1a } struct OSContext { u32 psr; // 0x0 u32 r0; // 0x4 u32 r1; // 0x8 u32 r2; // 0xc u32 r3; // 0x10 u32 r4; // 0x14 u32 r5; // 0x18 u32 r6; // 0x1c u32 r7; // 0x20 u32 r8; // 0x24 u32 r9; // 0x28 u32 r10; // 0x2c u32 r11; // 0x30 u32 r12; // 0x34 void *sp; // 0x38 void *lr; // 0x3c void *pc; // 0x40 void *kernelSp; // 0x44 struct OSFpContext fp; // 0x48 } struct OSThread { struct OSContext ctx; // 0x0 u32 state; // 0x64 struct OSThread *nextRunning; // 0x68 u32 threadId; // 0x6c u32 priority; // 0x70 u32 unknown; // 0x74 struct OSThreadQueue *queue; // 0x78 struct OSThreadLink linkQueue; // 0x7c u32 unknown2; // 0x80 struct OSMutex *mutex; // 0x84 - set to the mutex the thread is currently trying to lock struct OSMutexQueue queueMutex; // 0x88 // more unknown fields - the total length is not known } struct OSThreadQueue { struct OSThread *head; struct OSThread *tail; } struct OSThreadLink { struct OSThread *prev; struct OSThread *next; } struct OSMutex { struct OSThreadQueue waitingQueue; struct OSThread *holder; u32 timesLocked; struct OSMutex *next; struct OSMutex *prev; } struct OSMutexQueue { struct OSMutex *head; struct OSMutex *tail; }
Message queues
struct OSMessageQueue { struct OSThreadQueue waitForReceive; struct OSThreadQueue waitForSend; u32 *buf; u32 capacity; u32 rotation; u32 messagesEnqueued; }
Memory allocation
3 types of heaps exist: EXPH (exponential heap), FRMH (frame heap), and UNTH (unit heap).