Implement KSynchronizationObject
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include <initializer_list>
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <mesosphere/core/util.h>
|
||||
#include <mesosphere/core/util.hpp>
|
||||
#include <mesosphere/interfaces/ISlabAllocated.hpp>
|
||||
|
||||
namespace mesosphere
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <mesosphere/core/KAutoObject.hpp>
|
||||
#include <mesosphere/core/KLinkedList.hpp>
|
||||
|
||||
namespace mesosphere
|
||||
{
|
||||
|
||||
class KSynchronizationObject : public KAutoObject {
|
||||
public:
|
||||
|
||||
MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, SynchronizationObject);
|
||||
|
||||
virtual ~KSynchronizationObject();
|
||||
virtual bool IsSignaled() const = 0;
|
||||
|
||||
void Signal(); // Note: Signal() with !IsSignaled() is no-op
|
||||
|
||||
KLinkedList<KThread *>::const_iterator AddWaiter(KThread &thread);
|
||||
void RemoveWaiter(KLinkedList<KThread *>::const_iterator it);
|
||||
|
||||
private:
|
||||
KLinkedList<KThread *> waiters{};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <climits>
|
||||
#include <chrono>
|
||||
#include <boost/smart_ptr/intrusive_ptr.hpp>
|
||||
|
||||
#define MAX_CORES 4
|
||||
@@ -10,6 +11,8 @@
|
||||
namespace mesosphere
|
||||
{
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
using ushort = unsigned short;
|
||||
using uint = unsigned int;
|
||||
using ulong = unsigned long;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <mesosphere/core/util.hpp>
|
||||
#include <mesosphere/core/Handle.hpp>
|
||||
#include <mesosphere/core/Result.hpp>
|
||||
#include <mesosphere/core/KSynchronizationObject.hpp>
|
||||
#include <mesosphere/processes/KProcess.hpp>
|
||||
#include <mesosphere/interfaces/IAlarmable.hpp>
|
||||
#include <mesosphere/interfaces/ILimitedResource.hpp>
|
||||
@@ -206,6 +207,9 @@ class KThread final :
|
||||
/// Takes effect immediately
|
||||
void CancelKernelSync(Result res);
|
||||
|
||||
/// Takes effect when critical section is left
|
||||
void HandleSyncObjectSignaled(KSynchronizationObject *syncObj);
|
||||
|
||||
constexpr size_t GetNumberOfKMutexWaiters() const { return numKernelMutexWaiters; }
|
||||
constexpr uiptr GetWantedMutex() const { return wantedMutex; }
|
||||
void SetWantedMutex(uiptr mtx) { wantedMutex = mtx; }
|
||||
@@ -244,8 +248,8 @@ private:
|
||||
MutexWaitList mutexWaitList{};
|
||||
size_t numKernelMutexWaiters = 0;
|
||||
|
||||
Handle syncResultHandle{};
|
||||
Result syncResult = ResultSuccess();
|
||||
KSynchronizationObject *signaledSyncObject = nullptr;
|
||||
Result syncResult = ResultSuccess{};
|
||||
|
||||
u64 lastScheduledTime = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user