KThread: Difference between revisions
No edit summary |
No edit summary |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 7: | Line 7: | ||
{| class="wikitable" border="1" | {| class="wikitable" border="1" | ||
|- | |- | ||
! | ! Offset | ||
! Type | ! Type | ||
! | ! Description | ||
|- | |- | ||
| 0x0 | | 0x0 | ||
Line 45: | Line 45: | ||
| 0x34 | | 0x34 | ||
| u8 | | u8 | ||
| | | Scheduling mask | ||
|- | |- | ||
| 0x35 | | 0x35 | ||
| u8 | | u8 | ||
| | | Set to 1 when a thread is woken up from a svcSendSyncRequest call due to the ServerSession endpoint closing down | ||
|- | |- | ||
| 0x36 | | 0x36 | ||
Line 57: | Line 57: | ||
| 0x37 | | 0x37 | ||
| u8 | | u8 | ||
| | | Indicates there was an error translating the parameters in the command buffer during an IPC call | ||
|- | |- | ||
| 0x38 | | 0x38 | ||
Line 113: | Line 113: | ||
| 0x70 | | 0x70 | ||
| s32 | | s32 | ||
| Processor that created the thread | | Processor that created the thread (in the sense of "first ran") ; processor the thread is running in | ||
|- | |- | ||
| 0x74 | | 0x74 | ||
Line 125: | Line 125: | ||
| 0x7D | | 0x7D | ||
| u8 | | u8 | ||
| | | Thread has been terminated | ||
|- | |- | ||
| 0x7E | | 0x7E | ||
Line 169: | Line 169: | ||
| 0xAC | | 0xAC | ||
| s32 | | s32 | ||
| Priority | | Priority to restore after sleep if suspended, otherwise -1 | ||
|} | |} | ||
With the following declarations: <code>struct KThreadLinkedList { KThread *first, *last; };</code> and <code>struct KThreadLinkedListNode { KThread *prev, *next; };</code>. | With the following declarations: <code>struct KThreadLinkedList { KThread *first, *last; };</code> and <code>struct KThreadLinkedListNode { KThread *prev, *next; };</code>. | ||
=Thread Scheduling Mask= | |||
The thread scheduling mask is made of a low nibble (enum) and a high nibble (bitfield). | |||
Low nibble: | |||
{| class="wikitable" border="1" | |||
|- | |||
! Value | |||
! Description | |||
|- | |||
| 0 | |||
| The thread is not scheduled | |||
|- | |||
| 1 | |||
| The thread is scheduled | |||
|- | |||
| 2 | |||
| The thread is being terminated | |||
|} | |||
High nibble: | |||
{| class="wikitable" border="1" | |||
|- | |||
! Mask | |||
! Description | |||
|- | |||
| 0 | |||
| Nothing special | |||
|- | |||
| 0x8 (bit 3) | |||
| The thread has been debug-locked | |||
|} | |||
A thread is scheduled *if and only if* its (full) scheduling mask is exactly 1. This allows debug-(un)locking of threads to be done transparently. | |||
=Thread Affinity Mask= | =Thread Affinity Mask= | ||