summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2020-03-31 03:50:05 +0200
committerFernando Sahmkow <fsahmkow27@gmail.com>2020-06-27 17:36:03 +0200
commit19165cd859dcbb1f7d5e2c74c831e5196c2d1c41 (patch)
treeb8ce4801d50c76b77daae42d9ca9841a2ac82778 /src/core
parentSingleCore: Improve Cycle timing Behavior and replace mutex in global scheduler for spinlock. (diff)
downloadyuzu-19165cd859dcbb1f7d5e2c74c831e5196c2d1c41.tar
yuzu-19165cd859dcbb1f7d5e2c74c831e5196c2d1c41.tar.gz
yuzu-19165cd859dcbb1f7d5e2c74c831e5196c2d1c41.tar.bz2
yuzu-19165cd859dcbb1f7d5e2c74c831e5196c2d1c41.tar.lz
yuzu-19165cd859dcbb1f7d5e2c74c831e5196c2d1c41.tar.xz
yuzu-19165cd859dcbb1f7d5e2c74c831e5196c2d1c41.tar.zst
yuzu-19165cd859dcbb1f7d5e2c74c831e5196c2d1c41.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp1
-rw-r--r--src/core/hle/kernel/svc.cpp10
-rw-r--r--src/core/hle/kernel/thread.h9
3 files changed, 19 insertions, 1 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index e74d91670..9277b5d08 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -70,6 +70,7 @@ std::shared_ptr<WritableEvent> HLERequestContext::SleepClientThread(
});
const auto readable_event{writable_event->GetReadableEvent()};
writable_event->Clear();
+ thread->SetHLESyncObject(readable_event.get());
thread->SetStatus(ThreadStatus::WaitHLEEvent);
thread->SetSynchronizationResults(nullptr, RESULT_TIMEOUT);
readable_event->AddWaitingThread(thread);
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index c47fa9167..37e893c84 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -333,13 +333,21 @@ static ResultCode SendSyncRequest(Core::System& system, Handle handle) {
thread->SetStatus(ThreadStatus::WaitIPC);
session->SendSyncRequest(SharedFrom(thread), system.Memory());
}
+
if (thread->HasHLECallback()) {
Handle event_handle = thread->GetHLETimeEvent();
if (event_handle != InvalidHandle) {
auto& time_manager = system.Kernel().TimeManager();
time_manager.UnscheduleTimeEvent(event_handle);
}
- thread->InvokeHLECallback(SharedFrom(thread));
+
+ {
+ SchedulerLock lock(system.Kernel());
+ auto* sync_object = thread->GetHLESyncObject();
+ sync_object->RemoveWaitingThread(SharedFrom(thread));
+
+ thread->InvokeHLECallback(SharedFrom(thread));
+ }
}
return thread->GetSignalingResult();
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index f651d7822..61963148d 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -489,10 +489,18 @@ public:
hle_time_event = time_event;
}
+ void SetHLESyncObject(SynchronizationObject* object) {
+ hle_object = object;
+ }
+
Handle GetHLETimeEvent() const {
return hle_time_event;
}
+ SynchronizationObject* GetHLESyncObject() const {
+ return hle_object;
+ }
+
void InvalidateWakeupCallback() {
SetWakeupCallback(nullptr);
}
@@ -698,6 +706,7 @@ private:
/// Callback for HLE Events
HLECallback hle_callback;
Handle hle_time_event;
+ SynchronizationObject* hle_object;
Scheduler* scheduler = nullptr;