diff options
| author | 2018-04-20 14:42:29 -0500 | |
|---|---|---|
| committer | 2018-04-20 21:04:32 -0500 | |
| commit | 5fdfbfe25adafd2734a19fe94cccc58993cb12e7 (patch) | |
| tree | a4940a8231d08c5b96ce2d629acc04948ab1af3a /src/core/hle/kernel/mutex.h | |
| parent | Kernel: Properly implemented svcWaitProcessWideKey and svcSignalProcessWideKey (diff) | |
| download | yuzu-5fdfbfe25adafd2734a19fe94cccc58993cb12e7.tar.gz yuzu-5fdfbfe25adafd2734a19fe94cccc58993cb12e7.tar.xz yuzu-5fdfbfe25adafd2734a19fe94cccc58993cb12e7.zip | |
Kernel: Remove old and unused Mutex code.
Diffstat (limited to 'src/core/hle/kernel/mutex.h')
| -rw-r--r-- | src/core/hle/kernel/mutex.h | 82 |
1 files changed, 3 insertions, 79 deletions
diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h index 310923087..3117e7c70 100644 --- a/src/core/hle/kernel/mutex.h +++ b/src/core/hle/kernel/mutex.h | |||
| @@ -15,68 +15,8 @@ namespace Kernel { | |||
| 15 | 15 | ||
| 16 | class Thread; | 16 | class Thread; |
| 17 | 17 | ||
| 18 | class Mutex final : public WaitObject { | 18 | class Mutex final { |
| 19 | public: | 19 | public: |
| 20 | /** | ||
| 21 | * Creates a mutex. | ||
| 22 | * @param holding_thread Specifies a thread already holding the mutex. If not nullptr, this | ||
| 23 | * thread will acquire the mutex. | ||
| 24 | * @param guest_addr Address of the object tracking the mutex in guest memory. If specified, | ||
| 25 | * this mutex will update the guest object when its state changes. | ||
| 26 | * @param name Optional name of mutex | ||
| 27 | * @return Pointer to new Mutex object | ||
| 28 | */ | ||
| 29 | static SharedPtr<Mutex> Create(SharedPtr<Kernel::Thread> holding_thread, VAddr guest_addr = 0, | ||
| 30 | std::string name = "Unknown"); | ||
| 31 | |||
| 32 | std::string GetTypeName() const override { | ||
| 33 | return "Mutex"; | ||
| 34 | } | ||
| 35 | std::string GetName() const override { | ||
| 36 | return name; | ||
| 37 | } | ||
| 38 | |||
| 39 | static const HandleType HANDLE_TYPE = HandleType::Mutex; | ||
| 40 | HandleType GetHandleType() const override { | ||
| 41 | return HANDLE_TYPE; | ||
| 42 | } | ||
| 43 | |||
| 44 | u32 priority; ///< The priority of the mutex, used for priority inheritance. | ||
| 45 | std::string name; ///< Name of mutex (optional) | ||
| 46 | VAddr guest_addr; ///< Address of the guest mutex value | ||
| 47 | |||
| 48 | /** | ||
| 49 | * Elevate the mutex priority to the best priority | ||
| 50 | * among the priorities of all its waiting threads. | ||
| 51 | */ | ||
| 52 | void UpdatePriority(); | ||
| 53 | |||
| 54 | bool ShouldWait(Thread* thread) const override; | ||
| 55 | void Acquire(Thread* thread) override; | ||
| 56 | |||
| 57 | void AddWaitingThread(SharedPtr<Thread> thread) override; | ||
| 58 | void RemoveWaitingThread(Thread* thread) override; | ||
| 59 | |||
| 60 | /** | ||
| 61 | * Attempts to release the mutex from the specified thread. | ||
| 62 | * @param thread Thread that wants to release the mutex. | ||
| 63 | * @returns The result code of the operation. | ||
| 64 | */ | ||
| 65 | ResultCode Release(Thread* thread); | ||
| 66 | |||
| 67 | /// Gets the handle to the holding process stored in the guest state. | ||
| 68 | Handle GetOwnerHandle() const; | ||
| 69 | |||
| 70 | /// Gets the Thread pointed to by the owner handle | ||
| 71 | SharedPtr<Thread> GetHoldingThread() const; | ||
| 72 | /// Sets the holding process handle in the guest state. | ||
| 73 | void SetHoldingThread(SharedPtr<Thread> thread); | ||
| 74 | |||
| 75 | /// Returns the has_waiters bit in the guest state. | ||
| 76 | bool GetHasWaiters() const; | ||
| 77 | /// Sets the has_waiters bit in the guest state. | ||
| 78 | void SetHasWaiters(bool has_waiters); | ||
| 79 | |||
| 80 | /// Flag that indicates that a mutex still has threads waiting for it. | 20 | /// Flag that indicates that a mutex still has threads waiting for it. |
| 81 | static constexpr u32 MutexHasWaitersFlag = 0x40000000; | 21 | static constexpr u32 MutexHasWaitersFlag = 0x40000000; |
| 82 | /// Mask of the bits in a mutex address value that contain the mutex owner. | 22 | /// Mask of the bits in a mutex address value that contain the mutex owner. |
| @@ -90,24 +30,8 @@ public: | |||
| 90 | static ResultCode Release(VAddr address); | 30 | static ResultCode Release(VAddr address); |
| 91 | 31 | ||
| 92 | private: | 32 | private: |
| 93 | Mutex(); | 33 | Mutex() = default; |
| 94 | ~Mutex() override; | 34 | ~Mutex() = default; |
| 95 | |||
| 96 | /// Object in guest memory used to track the mutex state | ||
| 97 | union GuestState { | ||
| 98 | u32_le raw; | ||
| 99 | /// Handle of the thread that currently holds the mutex, 0 if available | ||
| 100 | BitField<0, 30, u32_le> holding_thread_handle; | ||
| 101 | /// 1 when there are threads waiting for this mutex, otherwise 0 | ||
| 102 | BitField<30, 1, u32_le> has_waiters; | ||
| 103 | }; | ||
| 104 | static_assert(sizeof(GuestState) == 4, "GuestState size is incorrect"); | ||
| 105 | }; | 35 | }; |
| 106 | 36 | ||
| 107 | /** | ||
| 108 | * Releases all the mutexes held by the specified thread | ||
| 109 | * @param thread Thread that is holding the mutexes | ||
| 110 | */ | ||
| 111 | void ReleaseThreadMutexes(Thread* thread); | ||
| 112 | |||
| 113 | } // namespace Kernel | 37 | } // namespace Kernel |