mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-13 22:54:24 -04:00
kern: kill the interrupt task manager thread
This commit is contained in:
parent
29cc3d1c09
commit
cb28150912
9 changed files with 112 additions and 140 deletions
|
@ -59,50 +59,6 @@ namespace ams::kern {
|
|||
#endif
|
||||
}
|
||||
|
||||
void KInterruptTaskManager::ThreadFunction(uintptr_t arg) {
|
||||
reinterpret_cast<KInterruptTaskManager *>(arg)->ThreadFunctionImpl();
|
||||
}
|
||||
|
||||
void KInterruptTaskManager::ThreadFunctionImpl() {
|
||||
MESOSPHERE_ASSERT_THIS();
|
||||
|
||||
while (true) {
|
||||
/* Get a task. */
|
||||
KInterruptTask *task = nullptr;
|
||||
{
|
||||
KScopedInterruptDisable di;
|
||||
|
||||
task = m_task_queue.GetHead();
|
||||
if (task == nullptr) {
|
||||
m_thread->SetState(KThread::ThreadState_Waiting);
|
||||
continue;
|
||||
}
|
||||
|
||||
m_task_queue.Dequeue();
|
||||
}
|
||||
|
||||
/* Do the task. */
|
||||
task->DoTask();
|
||||
|
||||
/* Destroy any objects we may need to close. */
|
||||
m_thread->DestroyClosedObjects();
|
||||
}
|
||||
}
|
||||
|
||||
void KInterruptTaskManager::Initialize() {
|
||||
/* Reserve a thread from the system limit. */
|
||||
MESOSPHERE_ABORT_UNLESS(Kernel::GetSystemResourceLimit().Reserve(ams::svc::LimitableResource_ThreadCountMax, 1));
|
||||
|
||||
/* Create and initialize the thread. */
|
||||
m_thread = KThread::Create();
|
||||
MESOSPHERE_ABORT_UNLESS(m_thread != nullptr);
|
||||
MESOSPHERE_R_ABORT_UNLESS(KThread::InitializeHighPriorityThread(m_thread, ThreadFunction, reinterpret_cast<uintptr_t>(this)));
|
||||
KThread::Register(m_thread);
|
||||
|
||||
/* Run the thread. */
|
||||
m_thread->Run();
|
||||
}
|
||||
|
||||
void KInterruptTaskManager::EnqueueTask(KInterruptTask *task) {
|
||||
MESOSPHERE_ASSERT(!KInterruptManager::AreInterruptsEnabled());
|
||||
|
||||
|
@ -111,4 +67,24 @@ namespace ams::kern {
|
|||
Kernel::GetScheduler().SetInterruptTaskRunnable();
|
||||
}
|
||||
|
||||
void KInterruptTaskManager::DoTasks() {
|
||||
/* Execute pending tasks. */
|
||||
const s64 start_time = KHardwareTimer::GetTick();
|
||||
for (KInterruptTask *task = m_task_queue.GetHead(); task != nullptr; task = m_task_queue.GetHead()) {
|
||||
/* Dequeue the task. */
|
||||
m_task_queue.Dequeue();
|
||||
|
||||
/* Do the task with interrupts temporarily enabled. */
|
||||
{
|
||||
KScopedInterruptEnable ei;
|
||||
|
||||
task->DoTask();
|
||||
}
|
||||
}
|
||||
const s64 end_time = KHardwareTimer::GetTick();
|
||||
|
||||
/* Increment the time we've spent executing. */
|
||||
m_cpu_time += end_time - start_time;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue