yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

kernel: additional style fixes to KThread, KProcess

This commit is contained in:
Liam 2023-03-11 10:38:33 -05:00
parent 9775a73d1a
commit c352381ce9
2 changed files with 27 additions and 27 deletions

View File

@ -137,16 +137,16 @@ u64 KProcess::GetTotalPhysicalMemoryAvailable() {
} }
u64 KProcess::GetTotalPhysicalMemoryAvailableWithoutSystemResource() { u64 KProcess::GetTotalPhysicalMemoryAvailableWithoutSystemResource() {
return GetTotalPhysicalMemoryAvailable() - GetSystemResourceSize(); return this->GetTotalPhysicalMemoryAvailable() - this->GetSystemResourceSize();
} }
u64 KProcess::GetTotalPhysicalMemoryUsed() { u64 KProcess::GetTotalPhysicalMemoryUsed() {
return m_image_size + m_main_thread_stack_size + m_page_table.GetNormalMemorySize() + return m_image_size + m_main_thread_stack_size + m_page_table.GetNormalMemorySize() +
GetSystemResourceSize(); this->GetSystemResourceSize();
} }
u64 KProcess::GetTotalPhysicalMemoryUsedWithoutSystemResource() { u64 KProcess::GetTotalPhysicalMemoryUsedWithoutSystemResource() {
return GetTotalPhysicalMemoryUsed() - GetSystemResourceUsage(); return this->GetTotalPhysicalMemoryUsed() - this->GetSystemResourceUsage();
} }
bool KProcess::ReleaseUserException(KThread* thread) { bool KProcess::ReleaseUserException(KThread* thread) {
@ -182,7 +182,7 @@ void KProcess::PinCurrentThread(s32 core_id) {
// If the thread isn't terminated, pin it. // If the thread isn't terminated, pin it.
if (!cur_thread->IsTerminationRequested()) { if (!cur_thread->IsTerminationRequested()) {
// Pin it. // Pin it.
PinThread(core_id, cur_thread); this->PinThread(core_id, cur_thread);
cur_thread->Pin(core_id); cur_thread->Pin(core_id);
// An update is needed. // An update is needed.
@ -199,7 +199,7 @@ void KProcess::UnpinCurrentThread(s32 core_id) {
// Unpin it. // Unpin it.
cur_thread->Unpin(); cur_thread->Unpin();
UnpinThread(core_id, cur_thread); this->UnpinThread(core_id, cur_thread);
// An update is needed. // An update is needed.
KScheduler::SetSchedulerUpdateNeeded(m_kernel); KScheduler::SetSchedulerUpdateNeeded(m_kernel);
@ -212,7 +212,7 @@ void KProcess::UnpinThread(KThread* thread) {
const auto core_id = thread->GetActiveCore(); const auto core_id = thread->GetActiveCore();
// Unpin it. // Unpin it.
UnpinThread(core_id, thread); this->UnpinThread(core_id, thread);
thread->Unpin(); thread->Unpin();
// An update is needed. // An update is needed.
@ -330,7 +330,7 @@ Result KProcess::SetActivity(ProcessActivity activity) {
} }
// Set ourselves as suspended. // Set ourselves as suspended.
SetSuspended(true); this->SetSuspended(true);
} else { } else {
ASSERT(activity == ProcessActivity::Runnable); ASSERT(activity == ProcessActivity::Runnable);
@ -343,7 +343,7 @@ Result KProcess::SetActivity(ProcessActivity activity) {
} }
// Set ourselves as resumed. // Set ourselves as resumed.
SetSuspended(false); this->SetSuspended(false);
} }
R_SUCCEED(); R_SUCCEED();
@ -457,7 +457,7 @@ void KProcess::PrepareForTermination() {
m_main_thread_stack_size + m_image_size); m_main_thread_stack_size + m_image_size);
} }
ChangeState(State::Terminated); this->ChangeState(State::Terminated);
} }
void KProcess::Finalize() { void KProcess::Finalize() {
@ -489,7 +489,7 @@ void KProcess::Finalize() {
m_page_table.Finalize(); m_page_table.Finalize();
// Perform inherited finalization. // Perform inherited finalization.
KAutoObjectWithSlabHeapAndContainer<KProcess, KWorkerTask>::Finalize(); KSynchronizationObject::Finalize();
} }
Result KProcess::CreateThreadLocalRegion(VAddr* out) { Result KProcess::CreateThreadLocalRegion(VAddr* out) {

View File

@ -206,7 +206,7 @@ Result KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack
m_argument = arg; m_argument = arg;
// Clear our stack parameters. // Clear our stack parameters.
std::memset(static_cast<void*>(std::addressof(GetStackParameters())), 0, std::memset(static_cast<void*>(std::addressof(this->GetStackParameters())), 0,
sizeof(StackParameters)); sizeof(StackParameters));
// Set parent, if relevant. // Set parent, if relevant.
@ -774,13 +774,13 @@ void KThread::WaitCancel() {
void KThread::TrySuspend() { void KThread::TrySuspend() {
ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel));
ASSERT(IsSuspendRequested()); ASSERT(this->IsSuspendRequested());
// Ensure that we have no waiters. // Ensure that we have no waiters.
if (GetNumKernelWaiters() > 0) { if (this->GetNumKernelWaiters() > 0) {
return; return;
} }
ASSERT(GetNumKernelWaiters() == 0); ASSERT(this->GetNumKernelWaiters() == 0);
// Perform the suspend. // Perform the suspend.
this->UpdateState(); this->UpdateState();
@ -916,7 +916,7 @@ Result KThread::GetThreadContext3(std::vector<u8>& out) {
KScopedSchedulerLock sl{m_kernel}; KScopedSchedulerLock sl{m_kernel};
// Verify that we're suspended. // Verify that we're suspended.
R_UNLESS(IsSuspendRequested(SuspendType::Thread), ResultInvalidState); R_UNLESS(this->IsSuspendRequested(SuspendType::Thread), ResultInvalidState);
// If we're not terminating, get the thread's user context. // If we're not terminating, get the thread's user context.
if (!this->IsTerminationRequested()) { if (!this->IsTerminationRequested()) {
@ -951,14 +951,14 @@ void KThread::AddHeldLock(LockWithPriorityInheritanceInfo* lock_info) {
m_held_lock_info_list.push_front(*lock_info); m_held_lock_info_list.push_front(*lock_info);
} }
KThread::LockWithPriorityInheritanceInfo* KThread::FindHeldLock(VAddr address_key_, KThread::LockWithPriorityInheritanceInfo* KThread::FindHeldLock(VAddr address_key,
bool is_kernel_address_key_) { bool is_kernel_address_key) {
ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel));
// Try to find an existing held lock. // Try to find an existing held lock.
for (auto& held_lock : m_held_lock_info_list) { for (auto& held_lock : m_held_lock_info_list) {
if (held_lock.GetAddressKey() == address_key_ && if (held_lock.GetAddressKey() == address_key &&
held_lock.GetIsKernelAddressKey() == is_kernel_address_key_) { held_lock.GetIsKernelAddressKey() == is_kernel_address_key) {
return std::addressof(held_lock); return std::addressof(held_lock);
} }
} }
@ -1166,7 +1166,7 @@ Result KThread::Run() {
// If we're not a kernel thread and we've been asked to suspend, suspend ourselves. // If we're not a kernel thread and we've been asked to suspend, suspend ourselves.
if (KProcess* owner = this->GetOwnerProcess(); owner != nullptr) { if (KProcess* owner = this->GetOwnerProcess(); owner != nullptr) {
if (IsUserThread() && IsSuspended()) { if (this->IsUserThread() && this->IsSuspended()) {
this->UpdateState(); this->UpdateState();
} }
owner->IncrementRunningThreadCount(); owner->IncrementRunningThreadCount();
@ -1201,7 +1201,7 @@ void KThread::Exit() {
m_suspend_allowed_flags = 0; m_suspend_allowed_flags = 0;
// Start termination. // Start termination.
StartTermination(); this->StartTermination();
// Register the thread as a work task. // Register the thread as a work task.
KWorkerTaskManager::AddTask(m_kernel, KWorkerTaskManager::WorkerType::Exit, this); KWorkerTaskManager::AddTask(m_kernel, KWorkerTaskManager::WorkerType::Exit, this);
@ -1285,7 +1285,7 @@ Result KThread::Sleep(s64 timeout) {
ASSERT(this == GetCurrentThreadPointer(m_kernel)); ASSERT(this == GetCurrentThreadPointer(m_kernel));
ASSERT(timeout > 0); ASSERT(timeout > 0);
ThreadQueueImplForKThreadSleep wait_queue_(m_kernel); ThreadQueueImplForKThreadSleep wait_queue(m_kernel);
KHardwareTimer* timer{}; KHardwareTimer* timer{};
{ {
// Setup the scheduling lock and sleep. // Setup the scheduling lock and sleep.
@ -1298,9 +1298,9 @@ Result KThread::Sleep(s64 timeout) {
} }
// Wait for the sleep to end. // Wait for the sleep to end.
wait_queue_.SetHardwareTimer(timer); wait_queue.SetHardwareTimer(timer);
this->BeginWait(std::addressof(wait_queue_)); this->BeginWait(std::addressof(wait_queue));
SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::Sleep); this->SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::Sleep);
} }
R_SUCCEED(); R_SUCCEED();
@ -1335,7 +1335,7 @@ void KThread::DummyThreadEndWait() {
void KThread::BeginWait(KThreadQueue* queue) { void KThread::BeginWait(KThreadQueue* queue) {
// Set our state as waiting. // Set our state as waiting.
SetState(ThreadState::Waiting); this->SetState(ThreadState::Waiting);
// Set our wait queue. // Set our wait queue.
m_wait_queue = queue; m_wait_queue = queue;
@ -1381,7 +1381,7 @@ void KThread::SetState(ThreadState state) {
KScopedSchedulerLock sl{m_kernel}; KScopedSchedulerLock sl{m_kernel};
// Clear debugging state // Clear debugging state
SetWaitReasonForDebugging({}); this->SetWaitReasonForDebugging({});
const ThreadState old_state = m_thread_state.load(std::memory_order_relaxed); const ThreadState old_state = m_thread_state.load(std::memory_order_relaxed);
m_thread_state.store( m_thread_state.store(