summaryrefslogtreecommitdiffstats
path: root/src/core/hle
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2022-10-17 06:01:50 +0200
committerLiam <byteslice@airmail.cc>2022-10-17 23:53:32 +0200
commit282cd3e5fe1ffe01d1ab008ef6b2a15266708d24 (patch)
treec6f0a93fdd0ef8e517d889b30d91be68c25ee9b2 /src/core/hle
parentMerge pull request #9058 from Docteh/new_transifex_cli (diff)
downloadyuzu-282cd3e5fe1ffe01d1ab008ef6b2a15266708d24.tar
yuzu-282cd3e5fe1ffe01d1ab008ef6b2a15266708d24.tar.gz
yuzu-282cd3e5fe1ffe01d1ab008ef6b2a15266708d24.tar.bz2
yuzu-282cd3e5fe1ffe01d1ab008ef6b2a15266708d24.tar.lz
yuzu-282cd3e5fe1ffe01d1ab008ef6b2a15266708d24.tar.xz
yuzu-282cd3e5fe1ffe01d1ab008ef6b2a15266708d24.tar.zst
yuzu-282cd3e5fe1ffe01d1ab008ef6b2a15266708d24.zip
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/kernel/k_slab_heap.h27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/core/hle/kernel/k_slab_heap.h b/src/core/hle/kernel/k_slab_heap.h
index 2b303537e..a8c77a7d4 100644
--- a/src/core/hle/kernel/k_slab_heap.h
+++ b/src/core/hle/kernel/k_slab_heap.h
@@ -8,6 +8,7 @@
#include "common/assert.h"
#include "common/common_funcs.h"
#include "common/common_types.h"
+#include "common/spin_lock.h"
namespace Kernel {
@@ -36,28 +37,34 @@ public:
}
void* Allocate() {
- Node* ret = m_head.load();
+ // KScopedInterruptDisable di;
- do {
- if (ret == nullptr) {
- break;
- }
- } while (!m_head.compare_exchange_weak(ret, ret->next));
+ m_lock.lock();
+
+ Node* ret = m_head;
+ if (ret != nullptr) [[likely]] {
+ m_head = ret->next;
+ }
+ m_lock.unlock();
return ret;
}
void Free(void* obj) {
+ // KScopedInterruptDisable di;
+
+ m_lock.lock();
+
Node* node = static_cast<Node*>(obj);
+ node->next = m_head;
+ m_head = node;
- Node* cur_head = m_head.load();
- do {
- node->next = cur_head;
- } while (!m_head.compare_exchange_weak(cur_head, node));
+ m_lock.unlock();
}
private:
std::atomic<Node*> m_head{};
+ Common::SpinLock m_lock;
};
} // namespace impl