mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-02 07:39:49 -04:00
util: better match true std::atomic semantics
This commit is contained in:
parent
c6d7174dd3
commit
aed9d3f535
12 changed files with 102 additions and 53 deletions
|
@ -66,7 +66,7 @@ namespace ams::kern {
|
|||
KSlabHeapImpl::Free(allocated + i);
|
||||
}
|
||||
|
||||
m_count.FetchAdd(sizeof(PageBuffer) / sizeof(T));
|
||||
m_count += sizeof(PageBuffer) / sizeof(T);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ namespace ams::kern {
|
|||
for (size_t i = 1; i < sizeof(PageBuffer) / sizeof(T); i++) {
|
||||
KSlabHeapImpl::Free(allocated + i);
|
||||
}
|
||||
m_count.FetchAdd(sizeof(PageBuffer) / sizeof(T));
|
||||
m_count += sizeof(PageBuffer) / sizeof(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ namespace ams::kern {
|
|||
std::construct_at(allocated);
|
||||
|
||||
/* Update our tracking. */
|
||||
size_t used = m_used.FetchAdd(1) + 1;
|
||||
const size_t used = ++m_used;
|
||||
size_t peak = m_peak.Load();
|
||||
while (peak < used) {
|
||||
if (m_peak.CompareExchangeWeak<std::memory_order_relaxed>(peak, used)) {
|
||||
|
@ -113,7 +113,7 @@ namespace ams::kern {
|
|||
|
||||
ALWAYS_INLINE void Free(T *t) {
|
||||
KSlabHeapImpl::Free(t);
|
||||
m_used.FetchSub(1);
|
||||
--m_used;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -288,7 +288,7 @@ namespace ams::kern {
|
|||
|
||||
KThread *GetExceptionThread() const { return m_exception_thread; }
|
||||
|
||||
void AddCpuTime(s64 diff) { m_cpu_time.FetchAdd(diff); }
|
||||
void AddCpuTime(s64 diff) { m_cpu_time += diff; }
|
||||
s64 GetCpuTime() { return m_cpu_time.Load(); }
|
||||
|
||||
constexpr s64 GetScheduledCount() const { return m_schedule_count; }
|
||||
|
|
|
@ -176,8 +176,6 @@ namespace ams::kern {
|
|||
};
|
||||
static_assert(ams::util::HasRedBlackKeyType<ConditionVariableComparator>);
|
||||
static_assert(std::same_as<ams::util::RedBlackKeyType<ConditionVariableComparator, void>, ConditionVariableComparator::RedBlackKeyType>);
|
||||
private:
|
||||
static constinit inline util::Atomic<u64> s_next_thread_id{0};
|
||||
private:
|
||||
util::IntrusiveListNode m_process_list_node{};
|
||||
util::IntrusiveRedBlackTreeNode m_condvar_arbiter_tree_node{};
|
||||
|
@ -348,11 +346,11 @@ namespace ams::kern {
|
|||
#endif
|
||||
|
||||
ALWAYS_INLINE void RegisterDpc(DpcFlag flag) {
|
||||
this->GetStackParameters().dpc_flags.FetchOr(flag);
|
||||
this->GetStackParameters().dpc_flags |= flag;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void ClearDpc(DpcFlag flag) {
|
||||
this->GetStackParameters().dpc_flags.FetchAnd(~flag);
|
||||
this->GetStackParameters().dpc_flags &= ~flag;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE u8 GetDpc() const {
|
||||
|
@ -544,7 +542,7 @@ namespace ams::kern {
|
|||
constexpr bool IsAttachedToDebugger() const { return m_debug_attached; }
|
||||
|
||||
void AddCpuTime(s32 core_id, s64 amount) {
|
||||
m_cpu_time.FetchAdd(amount);
|
||||
m_cpu_time += amount;
|
||||
/* TODO: Debug kernels track per-core tick counts. Should we? */
|
||||
MESOSPHERE_UNUSED(core_id);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue