summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Subv2018-04-20 14:45:52 -0500
committerGravatar Subv2018-04-20 21:04:33 -0500
commitbe155f4d9d410886853c25ffa032ce41a7428337 (patch)
tree0cdfd46181a5639339cbbf7d22ed31d9c1d8486b /src/core
parentKernel: Remove old and unused Mutex code. (diff)
downloadyuzu-be155f4d9d410886853c25ffa032ce41a7428337.tar.gz
yuzu-be155f4d9d410886853c25ffa032ce41a7428337.tar.xz
yuzu-be155f4d9d410886853c25ffa032ce41a7428337.zip
Kernel: Remove unused ConditionVariable class.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/hle/kernel/condition_variable.cpp64
-rw-r--r--src/core/hle/kernel/condition_variable.h63
-rw-r--r--src/core/hle/kernel/svc.cpp6
-rw-r--r--src/core/hle/kernel/thread.cpp9
-rw-r--r--src/core/hle/kernel/thread.h6
6 files changed, 0 insertions, 150 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index c1a645460..b3807c204 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -42,8 +42,6 @@ add_library(core STATIC
42 hle/kernel/client_port.h 42 hle/kernel/client_port.h
43 hle/kernel/client_session.cpp 43 hle/kernel/client_session.cpp
44 hle/kernel/client_session.h 44 hle/kernel/client_session.h
45 hle/kernel/condition_variable.cpp
46 hle/kernel/condition_variable.h
47 hle/kernel/errors.h 45 hle/kernel/errors.h
48 hle/kernel/event.cpp 46 hle/kernel/event.cpp
49 hle/kernel/event.h 47 hle/kernel/event.h
diff --git a/src/core/hle/kernel/condition_variable.cpp b/src/core/hle/kernel/condition_variable.cpp
deleted file mode 100644
index a786d7f74..000000000
--- a/src/core/hle/kernel/condition_variable.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/assert.h"
6#include "core/hle/kernel/condition_variable.h"
7#include "core/hle/kernel/errors.h"
8#include "core/hle/kernel/kernel.h"
9#include "core/hle/kernel/object_address_table.h"
10#include "core/hle/kernel/thread.h"
11
12namespace Kernel {
13
14ConditionVariable::ConditionVariable() {}
15ConditionVariable::~ConditionVariable() {}
16
17ResultVal<SharedPtr<ConditionVariable>> ConditionVariable::Create(VAddr guest_addr,
18 std::string name) {
19 SharedPtr<ConditionVariable> condition_variable(new ConditionVariable);
20
21 condition_variable->name = std::move(name);
22 condition_variable->guest_addr = guest_addr;
23 condition_variable->mutex_addr = 0;
24
25 // Condition variables are referenced by guest address, so track this in the kernel
26 g_object_address_table.Insert(guest_addr, condition_variable);
27
28 return MakeResult<SharedPtr<ConditionVariable>>(std::move(condition_variable));
29}
30
31bool ConditionVariable::ShouldWait(Thread* thread) const {
32 return GetAvailableCount() <= 0;
33}
34
35void ConditionVariable::Acquire(Thread* thread) {
36 if (GetAvailableCount() <= 0)
37 return;
38
39 SetAvailableCount(GetAvailableCount() - 1);
40}
41
42ResultCode ConditionVariable::Release(s32 target) {
43 if (target == -1) {
44 // When -1, wake up all waiting threads
45 SetAvailableCount(static_cast<s32>(GetWaitingThreads().size()));
46 WakeupAllWaitingThreads();
47 } else {
48 // Otherwise, wake up just a single thread
49 SetAvailableCount(target);
50 WakeupWaitingThread(GetHighestPriorityReadyThread());
51 }
52
53 return RESULT_SUCCESS;
54}
55
56s32 ConditionVariable::GetAvailableCount() const {
57 return Memory::Read32(guest_addr);
58}
59
60void ConditionVariable::SetAvailableCount(s32 value) const {
61 Memory::Write32(guest_addr, value);
62}
63
64} // namespace Kernel
diff --git a/src/core/hle/kernel/condition_variable.h b/src/core/hle/kernel/condition_variable.h
deleted file mode 100644
index 1c9f06769..000000000
--- a/src/core/hle/kernel/condition_variable.h
+++ /dev/null
@@ -1,63 +0,0 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <string>
8#include <queue>
9#include "common/common_types.h"
10#include "core/hle/kernel/kernel.h"
11#include "core/hle/kernel/wait_object.h"
12#include "core/hle/result.h"
13
14namespace Kernel {
15
16class ConditionVariable final : public WaitObject {
17public:
18 /**
19 * Creates a condition variable.
20 * @param guest_addr Address of the object tracking the condition variable in guest memory. If
21 * specified, this condition variable will update the guest object when its state changes.
22 * @param name Optional name of condition variable.
23 * @return The created condition variable.
24 */
25 static ResultVal<SharedPtr<ConditionVariable>> Create(VAddr guest_addr,
26 std::string name = "Unknown");
27
28 std::string GetTypeName() const override {
29 return "ConditionVariable";
30 }
31 std::string GetName() const override {
32 return name;
33 }
34
35 static const HandleType HANDLE_TYPE = HandleType::ConditionVariable;
36 HandleType GetHandleType() const override {
37 return HANDLE_TYPE;
38 }
39
40 s32 GetAvailableCount() const;
41 void SetAvailableCount(s32 value) const;
42
43 std::string name; ///< Name of condition variable (optional)
44 VAddr guest_addr; ///< Address of the guest condition variable value
45 VAddr mutex_addr; ///< (optional) Address of guest mutex value associated with this condition
46 ///< variable, used for implementing events
47
48 bool ShouldWait(Thread* thread) const override;
49 void Acquire(Thread* thread) override;
50
51 /**
52 * Releases a slot from a condition variable.
53 * @param target The number of threads to wakeup, -1 is all.
54 * @return ResultCode indicating if the operation succeeded.
55 */
56 ResultCode Release(s32 target);
57
58private:
59 ConditionVariable();
60 ~ConditionVariable() override;
61};
62
63} // namespace Kernel
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 99c1c2d2a..082c36caf 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -13,7 +13,6 @@
13#include "core/core_timing.h" 13#include "core/core_timing.h"
14#include "core/hle/kernel/client_port.h" 14#include "core/hle/kernel/client_port.h"
15#include "core/hle/kernel/client_session.h" 15#include "core/hle/kernel/client_session.h"
16#include "core/hle/kernel/condition_variable.h"
17#include "core/hle/kernel/event.h" 16#include "core/hle/kernel/event.h"
18#include "core/hle/kernel/handle_table.h" 17#include "core/hle/kernel/handle_table.h"
19#include "core/hle/kernel/mutex.h" 18#include "core/hle/kernel/mutex.h"
@@ -394,11 +393,6 @@ static ResultCode SetThreadPriority(Handle handle, u32 priority) {
394 } 393 }
395 394
396 thread->SetPriority(priority); 395 thread->SetPriority(priority);
397 thread->UpdatePriority();
398
399 // Update the mutexes that this thread is waiting for
400 for (auto& mutex : thread->pending_mutexes)
401 mutex->UpdatePriority();
402 396
403 Core::System::GetInstance().PrepareReschedule(); 397 Core::System::GetInstance().PrepareReschedule();
404 return RESULT_SUCCESS; 398 return RESULT_SUCCESS;
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 8093c4496..16d9b9e36 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -329,15 +329,6 @@ void Thread::SetPriority(u32 priority) {
329 nominal_priority = current_priority = priority; 329 nominal_priority = current_priority = priority;
330} 330}
331 331
332void Thread::UpdatePriority() {
333 u32 best_priority = nominal_priority;
334 for (auto& mutex : held_mutexes) {
335 if (mutex->priority < best_priority)
336 best_priority = mutex->priority;
337 }
338 BoostPriority(best_priority);
339}
340
341void Thread::BoostPriority(u32 priority) { 332void Thread::BoostPriority(u32 priority) {
342 Core::System::GetInstance().Scheduler().SetThreadPriority(this, priority); 333 Core::System::GetInstance().Scheduler().SetThreadPriority(this, priority);
343 current_priority = priority; 334 current_priority = priority;
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index 74d5904b8..ee13d20f1 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -104,12 +104,6 @@ public:
104 void SetPriority(u32 priority); 104 void SetPriority(u32 priority);
105 105
106 /** 106 /**
107 * Boost's a thread's priority to the best priority among the thread's held mutexes.
108 * This prevents priority inversion via priority inheritance.
109 */
110 void UpdatePriority();
111
112 /**
113 * Temporarily boosts the thread's priority until the next time it is scheduled 107 * Temporarily boosts the thread's priority until the next time it is scheduled
114 * @param priority The new priority 108 * @param priority The new priority
115 */ 109 */