Compare commits
1 Commits
master
...
lock-term-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d34400226b |
@@ -429,19 +429,23 @@ void KThread::StartTermination() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void KThread::FinishTermination() {
|
void KThread::FinishTermination() {
|
||||||
|
// Acquire the scheduler lock.
|
||||||
|
KScopedSchedulerLock lk{m_kernel};
|
||||||
|
|
||||||
// Ensure that the thread is not executing on any core.
|
// Ensure that the thread is not executing on any core.
|
||||||
if (m_parent != nullptr) {
|
if (m_parent != nullptr) {
|
||||||
for (std::size_t i = 0; i < static_cast<std::size_t>(Core::Hardware::NUM_CPU_CORES); ++i) {
|
bool wait_thread = true;
|
||||||
KThread* core_thread{};
|
lk.unlock();
|
||||||
do {
|
while (wait_thread) {
|
||||||
core_thread = m_kernel.Scheduler(i).GetSchedulerCurrentThread();
|
// now "pin" the scheduler so it wont change stuff mid-way
|
||||||
} while (core_thread == this);
|
lk.lock();
|
||||||
|
for (std::size_t i = 0; i < std::size_t(Core::Hardware::NUM_CPU_CORES); ++i)
|
||||||
|
is_on_schedule |= m_kernel.Scheduler(i).GetSchedulerCurrentThread() == this;
|
||||||
|
// let scheduler try again
|
||||||
|
if (wait_thread)
|
||||||
|
lk.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Acquire the scheduler lock.
|
|
||||||
KScopedSchedulerLock sl{m_kernel};
|
|
||||||
|
|
||||||
// Signal.
|
// Signal.
|
||||||
m_signaled = true;
|
m_signaled = true;
|
||||||
KSynchronizationObject::NotifyAvailable();
|
KSynchronizationObject::NotifyAvailable();
|
||||||
|
|||||||
Reference in New Issue
Block a user