meso: Implement LightSession functions
This commit is contained in:
@@ -11,12 +11,16 @@ namespace mesosphere
|
||||
class KLightSession;
|
||||
class KClientPort;
|
||||
|
||||
struct LightSessionRequest;
|
||||
|
||||
class KLightClientSession final : public KAutoObject, public IClient<KLightSession, KLightClientSession, KLightServerSession> {
|
||||
public:
|
||||
MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, LightClientSession);
|
||||
|
||||
virtual ~KLightClientSession();
|
||||
|
||||
Result SendSyncRequest(LightSessionRequest *request);
|
||||
|
||||
private:
|
||||
friend class KLightSession;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <mesosphere/core/util.hpp>
|
||||
#include <mesosphere/core/Result.hpp>
|
||||
#include <mesosphere/core/KSynchronizationObject.hpp>
|
||||
#include <mesosphere/core/KAutoObject.hpp>
|
||||
#include <mesosphere/interfaces/IServer.hpp>
|
||||
#include <mesosphere/threading/KThread.hpp>
|
||||
|
||||
@@ -15,17 +15,19 @@ class KLightClientSession;
|
||||
class KLightSession;
|
||||
class KClientPort;
|
||||
|
||||
struct LightSessionRequest;
|
||||
|
||||
struct LightServerSessionListTag;
|
||||
using LightServerSessionListBaseHook = boost::intrusive::list_base_hook<boost::intrusive::tag<LightServerSessionListTag> >;
|
||||
|
||||
class KLightServerSession final :
|
||||
public KSynchronizationObject,
|
||||
public KAutoObject,
|
||||
public IServer<KLightSession, KLightClientSession, KLightServerSession>,
|
||||
public LightServerSessionListBaseHook {
|
||||
|
||||
public:
|
||||
|
||||
MESOSPHERE_AUTO_OBJECT_TRAITS(SynchronizationObject, LightServerSession);
|
||||
MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, LightServerSession);
|
||||
|
||||
using List = typename boost::intrusive::make_list<
|
||||
KLightServerSession,
|
||||
@@ -35,8 +37,10 @@ class KLightServerSession final :
|
||||
|
||||
virtual ~KLightServerSession();
|
||||
|
||||
virtual bool IsSignaled() const override;
|
||||
/// Needs to be called from critical section
|
||||
Result HandleSyncRequest(KThread &sender);
|
||||
|
||||
Result ReplyAndReceive(LightSessionRequest *request);
|
||||
private:
|
||||
friend class KLightSession;
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
namespace mesosphere
|
||||
{
|
||||
|
||||
struct LightSessionRequest {
|
||||
s32 cmdId;
|
||||
u32 data[6];
|
||||
};
|
||||
|
||||
class KLightSession final :
|
||||
public KAutoObject,
|
||||
public ISetAllocated<KLightSession>,
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
namespace mesosphere
|
||||
{
|
||||
|
||||
struct LightSessionRequest;
|
||||
|
||||
struct KThreadContext;
|
||||
|
||||
struct ThreadWaitListTag;
|
||||
@@ -236,8 +238,12 @@ class KThread final :
|
||||
bool WaitForKernelSync(WaitList &waitList);
|
||||
/// Takes effect when critical section is left
|
||||
void ResumeFromKernelSync();
|
||||
/// Takes effect when critical section is left
|
||||
void ResumeFromKernelSync(Result res);
|
||||
/// Takes effect when critical section is left -- all threads in waitlist
|
||||
static void ResumeAllFromKernelSync(WaitList &waitList);
|
||||
/// Takes effect when critical section is left -- all threads in waitlist
|
||||
static void ResumeAllFromKernelSync(WaitList &waitList, Result res);
|
||||
/// Takes effect immediately
|
||||
void CancelKernelSync();
|
||||
/// Takes effect immediately
|
||||
@@ -250,10 +256,23 @@ class KThread final :
|
||||
void SetWaitingSync(bool isWaitingSync) { this->isWaitingSync = isWaitingSync; }
|
||||
constexpr bool IsSyncCancelled() const { return isSyncCancelled; }
|
||||
void SetSyncCancelled(bool isSyncCancelled) { this->isSyncCancelled = isSyncCancelled; }
|
||||
void ClearSync()
|
||||
{
|
||||
signaledSyncObject = nullptr;
|
||||
syncResult = ResultSuccess();
|
||||
}
|
||||
|
||||
constexpr Result GetSyncResult() const { return syncResult; }
|
||||
|
||||
/// Takes effect when critical section is left
|
||||
void HandleSyncObjectSignaled(KSynchronizationObject *syncObj);
|
||||
|
||||
LightSessionRequest *GetCurrentLightSessionRequest() const { return currentLightSessionRequest; }
|
||||
void SetCurrentLightSessionRequest(LightSessionRequest *currentLightSessionRequest)
|
||||
{
|
||||
this->currentLightSessionRequest = currentLightSessionRequest;
|
||||
}
|
||||
|
||||
template<typename Clock, typename Duration>
|
||||
Result WaitSynchronization(int &outId, KSynchronizationObject **syncObjs, int numSyncObjs, const std::chrono::time_point<Clock, Duration> &timeoutTime)
|
||||
{
|
||||
@@ -305,6 +324,7 @@ private:
|
||||
ulong affinityMask = 0;
|
||||
bool isSyncCancelled = false;
|
||||
bool isWaitingSync = false;
|
||||
LightSessionRequest *currentLightSessionRequest = nullptr; // located in kernel thread stacks
|
||||
uiptr wantedMutex = 0;
|
||||
KThread *wantedMutexOwner = nullptr;
|
||||
MutexWaitList mutexWaitList{};
|
||||
|
||||
Reference in New Issue
Block a user