Lifecycle management of threads #29

Merged
harraiken merged 240 commits from threads into master 2026-09-07 13:45:09 +02:00
2 changed files with 62 additions and 4 deletions
Showing only changes of commit f51c7a5ce5 - Show all commits

View File

@@ -12,6 +12,7 @@
#include <xtos.hh> #include <xtos.hh>
#include <ke/kthread.hh> #include <ke/kthread.hh>
#include <ke/proc.hh> #include <ke/proc.hh>
#include <ke/pushlock.hh>
#include <ke/spinlock.hh> #include <ke/spinlock.hh>
@@ -52,6 +53,66 @@ namespace KE
CriticalRegionGuard& operator=(const CriticalRegionGuard&) = delete; CriticalRegionGuard& operator=(const CriticalRegionGuard&) = delete;
}; };
class PushLockExclusiveGuard
{
private:
PKPUSH_LOCK Lock;
BOOLEAN Owned;
public:
PushLockExclusiveGuard(IN PKPUSH_LOCK PushLock,
IN BOOLEAN Acquire = TRUE)
{
Lock = PushLock;
Owned = Acquire;
if(Owned)
{
KE::PushLock::AcquireExclusivePushLock(Lock);
}
}
~PushLockExclusiveGuard()
{
if(Owned)
{
KE::PushLock::ReleaseExclusivePushLock(Lock);
}
}
PushLockExclusiveGuard(const PushLockExclusiveGuard&) = delete;
PushLockExclusiveGuard& operator=(const PushLockExclusiveGuard&) = delete;
};
class PushLockSharedGuard
{
private:
PKPUSH_LOCK Lock;
BOOLEAN Owned;
public:
PushLockSharedGuard(IN PKPUSH_LOCK PushLock,
IN BOOLEAN Acquire = TRUE)
{
Lock = PushLock;
Owned = Acquire;
if(Owned)
{
KE::PushLock::AcquireSharedPushLock(Lock);
}
}
~PushLockSharedGuard()
{
if(Owned)
{
KE::PushLock::ReleaseSharedPushLock(Lock);
}
}
PushLockSharedGuard(const PushLockSharedGuard&) = delete;
PushLockSharedGuard& operator=(const PushLockSharedGuard&) = delete;
};
class QueuedSpinLockGuard class QueuedSpinLockGuard
{ {
private: private:

View File

@@ -841,13 +841,10 @@ OB::LifeCycle::DeleteObject(IN PVOID Object,
{ {
/* Acquire exclusive access to the object type tracking list */ /* Acquire exclusive access to the object type tracking list */
KE::CriticalRegionGuard CriticalRegion; KE::CriticalRegionGuard CriticalRegion;
KE::PushLock::AcquireExclusivePushLock(&ObjectType->TypeLock); KE::PushLockExclusiveGuard PushLock(&ObjectType->TypeLock);
/* Unlink the object from the creator type list */ /* Unlink the object from the creator type list */
RTL::LinkedList::RemoveEntryList(&CreatorInfo->TypeList); RTL::LinkedList::RemoveEntryList(&CreatorInfo->TypeList);
/* Release the object type tracking list */
KE::PushLock::ReleaseExclusivePushLock(&ObjectType->TypeLock);
} }
/* Check if the object has an allocated name buffer */ /* Check if the object has an allocated name buffer */