mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-14 15:14:23 -04:00
kern/util: use custom atomics wrapper to substantially improve codegen
This commit is contained in:
parent
52332e8d75
commit
d74f364107
26 changed files with 688 additions and 260 deletions
|
@ -25,8 +25,8 @@ namespace ams::kern {
|
|||
constexpr u64 ProcessIdMin = InitialProcessIdMax + 1;
|
||||
constexpr u64 ProcessIdMax = std::numeric_limits<u64>::max();
|
||||
|
||||
std::atomic<u64> g_initial_process_id = InitialProcessIdMin;
|
||||
std::atomic<u64> g_process_id = ProcessIdMin;
|
||||
constinit util::Atomic<u64> g_initial_process_id{InitialProcessIdMin};
|
||||
constinit util::Atomic<u64> g_process_id{ProcessIdMin};
|
||||
|
||||
Result TerminateChildren(KProcess *process, const KThread *thread_to_not_terminate) {
|
||||
/* Request that all children threads terminate. */
|
||||
|
@ -299,7 +299,7 @@ namespace ams::kern {
|
|||
R_TRY(m_capabilities.Initialize(caps, num_caps, std::addressof(m_page_table)));
|
||||
|
||||
/* Initialize the process id. */
|
||||
m_process_id = g_initial_process_id++;
|
||||
m_process_id = g_initial_process_id.FetchAdd(1);
|
||||
MESOSPHERE_ABORT_UNLESS(InitialProcessIdMin <= m_process_id);
|
||||
MESOSPHERE_ABORT_UNLESS(m_process_id <= InitialProcessIdMax);
|
||||
|
||||
|
@ -409,7 +409,7 @@ namespace ams::kern {
|
|||
R_TRY(m_capabilities.Initialize(user_caps, num_caps, std::addressof(m_page_table)));
|
||||
|
||||
/* Initialize the process id. */
|
||||
m_process_id = g_process_id++;
|
||||
m_process_id = g_process_id.FetchAdd(1);
|
||||
MESOSPHERE_ABORT_UNLESS(ProcessIdMin <= m_process_id);
|
||||
MESOSPHERE_ABORT_UNLESS(m_process_id <= ProcessIdMax);
|
||||
|
||||
|
@ -789,15 +789,15 @@ namespace ams::kern {
|
|||
}
|
||||
|
||||
void KProcess::IncrementRunningThreadCount() {
|
||||
MESOSPHERE_ASSERT(m_num_running_threads.load() >= 0);
|
||||
MESOSPHERE_ASSERT(m_num_running_threads.Load() >= 0);
|
||||
|
||||
m_num_running_threads.fetch_add(1);
|
||||
m_num_running_threads.FetchAdd(1);
|
||||
}
|
||||
|
||||
void KProcess::DecrementRunningThreadCount() {
|
||||
MESOSPHERE_ASSERT(m_num_running_threads.load() > 0);
|
||||
MESOSPHERE_ASSERT(m_num_running_threads.Load() > 0);
|
||||
|
||||
if (m_num_running_threads.fetch_sub(1) == 1) {
|
||||
if (m_num_running_threads.FetchSub(1) == 1) {
|
||||
this->Terminate();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue