Kernel: Scheduler::unblock_thread() wakes sleeping threads

This commit is contained in:
Bananymous 2023-12-06 16:12:37 +02:00
parent 976ae64f88
commit 534969df32
2 changed files with 18 additions and 2 deletions

View File

@ -23,6 +23,7 @@ namespace Kernel
void block_current_thread(Semaphore*);
void unblock_threads(Semaphore*);
// Makes sleeping or blocked thread with tid active.
void unblock_thread(pid_t tid);
Thread& current_thread();

View File

@ -351,8 +351,23 @@ namespace Kernel
{
if (it->thread->tid() == tid)
{
auto thread = it->thread;
it = m_blocking_threads.remove(it);
Thread* thread = it->thread;
m_blocking_threads.remove(it);
// This should work as we released enough memory from active thread
static_assert(sizeof(ActiveThread) == sizeof(BlockingThread));
MUST(m_active_threads.emplace_back(thread));
return;
}
}
for (auto it = m_sleeping_threads.begin(); it != m_sleeping_threads.end(); it++)
{
if (it->thread->tid() == tid)
{
Thread* thread = it->thread;
m_sleeping_threads.remove(it);
// This should work as we released enough memory from active thread
static_assert(sizeof(ActiveThread) == sizeof(BlockingThread));