Skip to content

Commit

Permalink
Fixed a bug concerning the scheduling of the idle thread
Browse files Browse the repository at this point in the history
  • Loading branch information
ergo720 committed Aug 19, 2024
1 parent cf28937 commit ed40a1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions nboxkrnl/ke/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,13 @@ static PKTHREAD XBOXAPI KiFindAndRemoveHighestPriorityThread(KPRIORITY LowPriori
{
assert(KeGetCurrentIrql() == DISPATCH_LEVEL);

if (KiReadyThreadMask == 0) {
return nullptr;
}

KPRIORITY HighestPriority;
__asm {
bsr eax, KiReadyThreadMask
mov ecx, -1
cmovz eax, ecx
mov HighestPriority, eax
}

Expand Down
2 changes: 1 addition & 1 deletion nboxkrnl/ki/ki.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ inline uint8_t alignas(4) KiIdleThreadStack[KERNEL_STACK_SIZE];
inline LIST_ENTRY KiReadyThreadLists[NUM_OF_THREAD_PRIORITIES];

// Bitmask of KiReadyThreadLists -> bit position is one if there is at least one ready thread at that priority
inline DWORD KiReadyThreadMask = 1;
inline DWORD KiReadyThreadMask = 0;

inline LIST_ENTRY KiWaitInListHead;

Expand Down

0 comments on commit ed40a1a

Please sign in to comment.