Kernel: Scheduler can now block threads based on tid
This commit is contained in:
parent
cc8af25d73
commit
146802fa4c
|
@ -26,6 +26,7 @@ namespace Kernel
|
|||
|
||||
void block_current_thread(Semaphore*);
|
||||
void unblock_threads(Semaphore*);
|
||||
void unblock_thread(pid_t tid);
|
||||
|
||||
Thread& current_thread();
|
||||
static pid_t current_tid();
|
||||
|
|
|
@ -351,7 +351,26 @@ namespace Kernel
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue