mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-03 08:08:39 -04:00
kern: KAutoObject destruction is now scheduled for next dpc-time
This commit is contained in:
parent
15956fcf9a
commit
4407237f5b
7 changed files with 94 additions and 18 deletions
|
@ -174,13 +174,20 @@ namespace ams::kern {
|
|||
MESOSPHERE_ASSERT(!KInterruptManager::AreInterruptsEnabled());
|
||||
MESOSPHERE_ASSERT(!KScheduler::IsSchedulerLockedByCurrentThread());
|
||||
|
||||
/* The only deferred procedure supported by Horizon is thread termination. */
|
||||
/* Check if we need to terminate the current thread. */
|
||||
KThread *cur_thread = GetCurrentThreadPointer();
|
||||
if (cur_thread->IsTerminationRequested()) {
|
||||
KScopedInterruptEnable ei;
|
||||
cur_thread->Exit();
|
||||
/* Get reference to the current thread. */
|
||||
KThread &cur_thread = GetCurrentThread();
|
||||
|
||||
/* Enable interrupts, temporarily. */
|
||||
KScopedInterruptEnable ei;
|
||||
|
||||
/* If the thread is scheduled for termination, exit the thread. */
|
||||
if (cur_thread.IsTerminationRequested()) {
|
||||
cur_thread.Exit();
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
/* We may also need to destroy any closed objects. */
|
||||
cur_thread.DestroyClosedObjects();
|
||||
}
|
||||
|
||||
void KDpcManager::Sync() {
|
||||
|
|
|
@ -83,6 +83,9 @@ namespace ams::kern {
|
|||
|
||||
/* Do the task. */
|
||||
task->DoTask();
|
||||
|
||||
/* Destroy any objects we may need to close. */
|
||||
m_thread->DestroyClosedObjects();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -155,8 +155,9 @@ namespace ams::kern {
|
|||
m_lock_owner = nullptr;
|
||||
m_num_core_migration_disables = 0;
|
||||
|
||||
/* We have no waiters, but we do have an entrypoint. */
|
||||
/* We have no waiters, and no closed objects. */
|
||||
m_num_kernel_waiters = 0;
|
||||
m_closed_object = nullptr;
|
||||
|
||||
/* Set our current core id. */
|
||||
m_current_core_id = phys_core;
|
||||
|
@ -1157,6 +1158,9 @@ namespace ams::kern {
|
|||
m_parent->DecrementRunningThreadCount();
|
||||
}
|
||||
|
||||
/* Destroy any dependent objects. */
|
||||
this->DestroyClosedObjects();
|
||||
|
||||
/* Perform termination. */
|
||||
{
|
||||
KScopedSchedulerLock sl;
|
||||
|
|
|
@ -68,6 +68,9 @@ namespace ams::kern {
|
|||
|
||||
/* Do the task. */
|
||||
task->DoWorkerTask();
|
||||
|
||||
/* Destroy any objects we may need to close. */
|
||||
m_thread->DestroyClosedObjects();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,12 +74,17 @@ namespace ams::kern::svc {
|
|||
|
||||
/* Wait for a message. */
|
||||
while (true) {
|
||||
/* Close any pending objects before we wait. */
|
||||
GetCurrentThread().DestroyClosedObjects();
|
||||
|
||||
/* Wait for an object. */
|
||||
s32 index;
|
||||
Result result = KSynchronizationObject::Wait(std::addressof(index), objs, num_objects, timeout);
|
||||
if (svc::ResultTimedOut::Includes(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Receive the request. */
|
||||
if (R_SUCCEEDED(result)) {
|
||||
KServerSession *session = objs[index]->DynamicCast<KServerSession *>();
|
||||
if (session != nullptr) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue