1
0
Fork 0
forked from suyu/suyu

KThread: Send termination interrupt to all cores a thread has affinity to

KThread::RequestTerminate may run from a thread which is not the CurrentCore, and thus
masking this out is erroneous.
This commit is contained in:
Merry 2024-01-02 21:13:04 +00:00
parent 148ad0cf0b
commit 0f7fc94111

View file

@ -1258,11 +1258,11 @@ ThreadState KThread::RequestTerminate() {
// Change the thread's priority to be higher than any system thread's. // Change the thread's priority to be higher than any system thread's.
this->IncreaseBasePriority(TerminatingThreadPriority); this->IncreaseBasePriority(TerminatingThreadPriority);
// If the thread is runnable, send a termination interrupt to other cores. // If the thread is runnable, send a termination interrupt to cores it may be running on.
if (this->GetState() == ThreadState::Runnable) { if (this->GetState() == ThreadState::Runnable) {
if (const u64 core_mask = m_physical_affinity_mask.GetAffinityMask() & // NOTE: We do not mask the "current core", because this code may not actually be
~(1ULL << GetCurrentCoreId(m_kernel)); // executing from the thread representing the "current core".
core_mask != 0) { if (const u64 core_mask = m_physical_affinity_mask.GetAffinityMask(); core_mask != 0) {
Kernel::KInterruptManager::SendInterProcessorInterrupt(m_kernel, core_mask); Kernel::KInterruptManager::SendInterProcessorInterrupt(m_kernel, core_mask);
} }
} }