[Threading] Implement priority boost on wake

When a thread wakes from a kernel wait, the Xenon scheduler boosts its
effective priority by the increment passed to the signaling call
(KeSetEvent, KeReleaseSemaphore, KeReleaseMutant). The boost is clamped
to the per-thread max_dynamic_priority cap, respects the guest
boost_disabled flag, and is drained on the next quantum expiry.
Guest KTHREAD priority fields are now initialized from parent process
defaults, and the previously unknown fields involved have been renamed
to match their identified purpose.
This commit is contained in:
Herman S.
2026-04-11 17:05:05 +09:00
parent b3d8a21b72
commit 65b74819aa
9 changed files with 127 additions and 47 deletions

View File

@@ -1312,15 +1312,16 @@ void KernelState::EmulateCPInterruptDPC(uint32_t interrupt_callback,
}
void KernelState::InitializeProcess(X_KPROCESS* process, uint32_t type,
char unk_18, char unk_19, char unk_1A) {
char priority_class, char default_priority,
char max_dynamic_priority) {
uint32_t guest_kprocess = memory()->HostToGuestVirtual(process);
uint32_t thread_list_guest_ptr =
guest_kprocess + offsetof(X_KPROCESS, thread_list);
process->unk_18 = unk_18;
process->unk_19 = unk_19;
process->unk_1A = unk_1A;
process->process_priority_class = priority_class;
process->default_thread_priority = default_priority;
process->max_dynamic_priority = max_dynamic_priority;
util::XeInitializeListHead(&process->thread_list, thread_list_guest_ptr);
process->quantum = 60;
// doubt any guest code uses this ptr, which i think probably has something to
@@ -1328,7 +1329,7 @@ void KernelState::InitializeProcess(X_KPROCESS* process, uint32_t type,
process->clrdataa_masked_ptr = 0;
// clrdataa_ & ~(1U << 31);
process->thread_count = 0;
process->unk_1B = 0x06;
process->disable_quantum_decay = 0x06;
process->kernel_stack_size = 16 * 1024;
process->tls_slot_size = 0x80;