Kernel: Scheduler can now block threads based on tid

This commit is contained in:
Bananymous 2023-07-24 22:24:21 +03:00
parent cc8af25d73
commit 146802fa4c
2 changed files with 20 additions and 0 deletions

View File

@ -26,6 +26,7 @@ namespace Kernel
void block_current_thread(Semaphore*); void block_current_thread(Semaphore*);
void unblock_threads(Semaphore*); void unblock_threads(Semaphore*);
void unblock_thread(pid_t tid);
Thread& current_thread(); Thread& current_thread();
static pid_t current_tid(); static pid_t current_tid();

View File

@ -351,7 +351,26 @@ namespace Kernel
it++; it++;
} }
} }
}
void Scheduler::unblock_thread(pid_t tid)
{
CriticalScope _;
for (auto it = m_blocking_threads.begin(); it != m_blocking_threads.end(); it++)
{
if (it->thread->tid() == tid)
{
auto thread = it->thread;
it = 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;
}
}
} }
} }