Difference between revisions of "KScheduler"

From 3dbrew
Jump to navigation Jump to search
Line 45: Line 45:
 
| s16
 
| s16
 
| Count of threads currently being managed by this scheduler object
 
| Count of threads currently being managed by this scheduler object
 +
|-
 +
| 0x14
 +
| u32
 +
| Bit field for high priority threads in KScheduler(0-31)
 +
|-
 +
| 0x18
 +
| u32
 +
| Bit field for low priority threads in KScheduler(32-63)\
 +
|-
 +
| 0x1C
 +
| KThread*
 +
| Scheduler thread
 +
|-
 +
| 0x20
 +
| u32
 +
| Unknown
 +
|-
 +
| 0x24
 +
| u32
 +
| Unknown/unused
 
|}
 
|}
  
  
 
There is 1 KScheduler object per core.
 
There is 1 KScheduler object per core.
 +
 +
Each priority of KThread has a pair of KThread object pointers below the KScheduler object.  Each pair of pointers makes up 1 entry in that core's Scheduler for their priority.  The first KThread in the entry is the first KThread in the linked list and the second is the last KThread in the linked list of KThreads in the scheduler that have the same priority.
 +
 +
 +
Priority bit fields:
 +
 +
Each bit field goes from the most significant bit to the least significant bit, high priority to low priority.  This means, for example, that bit 31 in the high priority bit field is for priority 0 and bit 0 is for priority 31.  These fields are set when a KThread with the corresponding priority is added for scheduling and are cleared when the last KThread in the linked list for a given priority is removed from the scheduler.

Revision as of 04:18, 19 March 2015


Size : 0x228 bytes


Offset Type Description
0x0 u32 Pointer to vtable
0x4 u32 Unused, may have been for reference count
0x8 u32 Count for thread switches - this is only added to if a context switch function runs but exits because the scheduler is locked by another thread.
0xC bool Context switch needed
0xD bool Context switch started during interrupt
0xE bool Trigger CPU cross-core interrupt (interrupt 8)
0xF bool Post-interrupt rescheduling needed
0x10 s16 Scheduler core number
0x12 s16 Count of threads currently being managed by this scheduler object
0x14 u32 Bit field for high priority threads in KScheduler(0-31)
0x18 u32 Bit field for low priority threads in KScheduler(32-63)\
0x1C KThread* Scheduler thread
0x20 u32 Unknown
0x24 u32 Unknown/unused


There is 1 KScheduler object per core.

Each priority of KThread has a pair of KThread object pointers below the KScheduler object. Each pair of pointers makes up 1 entry in that core's Scheduler for their priority. The first KThread in the entry is the first KThread in the linked list and the second is the last KThread in the linked list of KThreads in the scheduler that have the same priority.


Priority bit fields:

Each bit field goes from the most significant bit to the least significant bit, high priority to low priority. This means, for example, that bit 31 in the high priority bit field is for priority 0 and bit 0 is for priority 31. These fields are set when a KThread with the corresponding priority is added for scheduling and are cleared when the last KThread in the linked list for a given priority is removed from the scheduler.