Added GetLocksCount()

This commit is contained in:
Alex 2023-02-24 10:11:48 +02:00
parent 3e76830978
commit bcf46f8341
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
2 changed files with 13 additions and 0 deletions

View File

@ -6,6 +6,9 @@
#include "../kernel.h"
bool ForceUnlock = false;
Atomic<size_t> LocksCount = 0;
size_t GetLocksCount() { return LocksCount; }
void LockClass::DeadLock(SpinLockData Lock)
{
@ -62,6 +65,7 @@ Retry:
CPUData *CoreData = GetCurrentCPU();
if (CoreData != nullptr)
LockData.Core = CoreData->ID;
LocksCount++;
__sync;
return 0;
@ -73,6 +77,7 @@ int LockClass::Unlock()
IsLocked.Store(false, MemoryOrder::Release);
LockData.Count--;
IsLocked = false;
LocksCount--;
return 0;
}
@ -125,6 +130,7 @@ Retry:
CPUData *CoreData = GetCurrentCPU();
if (CoreData != nullptr)
LockData.Core = CoreData->ID;
LocksCount++;
__sync;
return 0;

View File

@ -11,6 +11,13 @@
/* Enabled ONLY on crash. */
extern bool ForceUnlock;
/**
* @brief Get how many locks are currently in use.
*
* @return size_t
*/
size_t GetLocksCount();
/** @brief Please use this macro to create a new lock. */
class LockClass
{