mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-29 10:32:30 -06:00
Merge pull request #4224 from FearlessTobi/port-1310
Port #734 and #1310 from yuzu: Changes to Thread-related enums
This commit is contained in:
commit
f05740a5fd
13 changed files with 126 additions and 124 deletions
|
@ -145,32 +145,32 @@ QString WaitTreeThread::GetText() const {
|
||||||
const auto& thread = static_cast<const Kernel::Thread&>(object);
|
const auto& thread = static_cast<const Kernel::Thread&>(object);
|
||||||
QString status;
|
QString status;
|
||||||
switch (thread.status) {
|
switch (thread.status) {
|
||||||
case THREADSTATUS_RUNNING:
|
case Kernel::ThreadStatus::Running:
|
||||||
status = tr("running");
|
status = tr("running");
|
||||||
break;
|
break;
|
||||||
case THREADSTATUS_READY:
|
case Kernel::ThreadStatus::Ready:
|
||||||
status = tr("ready");
|
status = tr("ready");
|
||||||
break;
|
break;
|
||||||
case THREADSTATUS_WAIT_ARB:
|
case Kernel::ThreadStatus::WaitArb:
|
||||||
status = tr("waiting for address 0x%1").arg(thread.wait_address, 8, 16, QLatin1Char('0'));
|
status = tr("waiting for address 0x%1").arg(thread.wait_address, 8, 16, QLatin1Char('0'));
|
||||||
break;
|
break;
|
||||||
case THREADSTATUS_WAIT_SLEEP:
|
case Kernel::ThreadStatus::WaitSleep:
|
||||||
status = tr("sleeping");
|
status = tr("sleeping");
|
||||||
break;
|
break;
|
||||||
case THREADSTATUS_WAIT_IPC:
|
case Kernel::ThreadStatus::WaitIPC:
|
||||||
status = tr("waiting for IPC response");
|
status = tr("waiting for IPC response");
|
||||||
break;
|
break;
|
||||||
case THREADSTATUS_WAIT_SYNCH_ALL:
|
case Kernel::ThreadStatus::WaitSynchAll:
|
||||||
case THREADSTATUS_WAIT_SYNCH_ANY:
|
case Kernel::ThreadStatus::WaitSynchAny:
|
||||||
status = tr("waiting for objects");
|
status = tr("waiting for objects");
|
||||||
break;
|
break;
|
||||||
case THREADSTATUS_WAIT_HLE_EVENT:
|
case Kernel::ThreadStatus::WaitHleEvent:
|
||||||
status = tr("waiting for HLE return");
|
status = tr("waiting for HLE return");
|
||||||
break;
|
break;
|
||||||
case THREADSTATUS_DORMANT:
|
case Kernel::ThreadStatus::Dormant:
|
||||||
status = tr("dormant");
|
status = tr("dormant");
|
||||||
break;
|
break;
|
||||||
case THREADSTATUS_DEAD:
|
case Kernel::ThreadStatus::Dead:
|
||||||
status = tr("dead");
|
status = tr("dead");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -183,23 +183,23 @@ QString WaitTreeThread::GetText() const {
|
||||||
QColor WaitTreeThread::GetColor() const {
|
QColor WaitTreeThread::GetColor() const {
|
||||||
const auto& thread = static_cast<const Kernel::Thread&>(object);
|
const auto& thread = static_cast<const Kernel::Thread&>(object);
|
||||||
switch (thread.status) {
|
switch (thread.status) {
|
||||||
case THREADSTATUS_RUNNING:
|
case Kernel::ThreadStatus::Running:
|
||||||
return QColor(Qt::GlobalColor::darkGreen);
|
return QColor(Qt::GlobalColor::darkGreen);
|
||||||
case THREADSTATUS_READY:
|
case Kernel::ThreadStatus::Ready:
|
||||||
return QColor(Qt::GlobalColor::darkBlue);
|
return QColor(Qt::GlobalColor::darkBlue);
|
||||||
case THREADSTATUS_WAIT_ARB:
|
case Kernel::ThreadStatus::WaitArb:
|
||||||
return QColor(Qt::GlobalColor::darkRed);
|
return QColor(Qt::GlobalColor::darkRed);
|
||||||
case THREADSTATUS_WAIT_SLEEP:
|
case Kernel::ThreadStatus::WaitSleep:
|
||||||
return QColor(Qt::GlobalColor::darkYellow);
|
return QColor(Qt::GlobalColor::darkYellow);
|
||||||
case THREADSTATUS_WAIT_IPC:
|
case Kernel::ThreadStatus::WaitIPC:
|
||||||
return QColor(Qt::GlobalColor::darkCyan);
|
return QColor(Qt::GlobalColor::darkCyan);
|
||||||
case THREADSTATUS_WAIT_SYNCH_ALL:
|
case Kernel::ThreadStatus::WaitSynchAll:
|
||||||
case THREADSTATUS_WAIT_SYNCH_ANY:
|
case Kernel::ThreadStatus::WaitSynchAny:
|
||||||
case THREADSTATUS_WAIT_HLE_EVENT:
|
case Kernel::ThreadStatus::WaitHleEvent:
|
||||||
return QColor(Qt::GlobalColor::red);
|
return QColor(Qt::GlobalColor::red);
|
||||||
case THREADSTATUS_DORMANT:
|
case Kernel::ThreadStatus::Dormant:
|
||||||
return QColor(Qt::GlobalColor::darkCyan);
|
return QColor(Qt::GlobalColor::darkCyan);
|
||||||
case THREADSTATUS_DEAD:
|
case Kernel::ThreadStatus::Dead:
|
||||||
return QColor(Qt::GlobalColor::gray);
|
return QColor(Qt::GlobalColor::gray);
|
||||||
default:
|
default:
|
||||||
return WaitTreeItem::GetColor();
|
return WaitTreeItem::GetColor();
|
||||||
|
@ -213,16 +213,16 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const {
|
||||||
|
|
||||||
QString processor;
|
QString processor;
|
||||||
switch (thread.processor_id) {
|
switch (thread.processor_id) {
|
||||||
case ThreadProcessorId::THREADPROCESSORID_DEFAULT:
|
case Kernel::ThreadProcessorId::ThreadProcessorIdDefault:
|
||||||
processor = tr("default");
|
processor = tr("default");
|
||||||
break;
|
break;
|
||||||
case ThreadProcessorId::THREADPROCESSORID_ALL:
|
case Kernel::ThreadProcessorId::ThreadProcessorIdAll:
|
||||||
processor = tr("all");
|
processor = tr("all");
|
||||||
break;
|
break;
|
||||||
case ThreadProcessorId::THREADPROCESSORID_0:
|
case Kernel::ThreadProcessorId::ThreadProcessorId0:
|
||||||
processor = tr("AppCore");
|
processor = tr("AppCore");
|
||||||
break;
|
break;
|
||||||
case ThreadProcessorId::THREADPROCESSORID_1:
|
case Kernel::ThreadProcessorId::ThreadProcessorId1:
|
||||||
processor = tr("SysCore");
|
processor = tr("SysCore");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -243,9 +243,9 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const {
|
||||||
} else {
|
} else {
|
||||||
list.push_back(std::make_unique<WaitTreeMutexList>(thread.held_mutexes));
|
list.push_back(std::make_unique<WaitTreeMutexList>(thread.held_mutexes));
|
||||||
}
|
}
|
||||||
if (thread.status == THREADSTATUS_WAIT_SYNCH_ANY ||
|
if (thread.status == Kernel::ThreadStatus::WaitSynchAny ||
|
||||||
thread.status == THREADSTATUS_WAIT_SYNCH_ALL ||
|
thread.status == Kernel::ThreadStatus::WaitSynchAll ||
|
||||||
thread.status == THREADSTATUS_WAIT_HLE_EVENT) {
|
thread.status == Kernel::ThreadStatus::WaitHleEvent) {
|
||||||
list.push_back(std::make_unique<WaitTreeObjectList>(thread.wait_objects,
|
list.push_back(std::make_unique<WaitTreeObjectList>(thread.wait_objects,
|
||||||
thread.IsSleepingOnWaitAll()));
|
thread.IsSleepingOnWaitAll()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Kernel {
|
||||||
|
|
||||||
void AddressArbiter::WaitThread(SharedPtr<Thread> thread, VAddr wait_address) {
|
void AddressArbiter::WaitThread(SharedPtr<Thread> thread, VAddr wait_address) {
|
||||||
thread->wait_address = wait_address;
|
thread->wait_address = wait_address;
|
||||||
thread->status = THREADSTATUS_WAIT_ARB;
|
thread->status = ThreadStatus::WaitArb;
|
||||||
waiting_threads.emplace_back(std::move(thread));
|
waiting_threads.emplace_back(std::move(thread));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ void AddressArbiter::ResumeAllThreads(VAddr address) {
|
||||||
// Determine which threads are waiting on this address, those should be woken up.
|
// Determine which threads are waiting on this address, those should be woken up.
|
||||||
auto itr = std::stable_partition(waiting_threads.begin(), waiting_threads.end(),
|
auto itr = std::stable_partition(waiting_threads.begin(), waiting_threads.end(),
|
||||||
[address](const auto& thread) {
|
[address](const auto& thread) {
|
||||||
ASSERT_MSG(thread->status == THREADSTATUS_WAIT_ARB,
|
ASSERT_MSG(thread->status == ThreadStatus::WaitArb,
|
||||||
"Inconsistent AddressArbiter state");
|
"Inconsistent AddressArbiter state");
|
||||||
return thread->wait_address != address;
|
return thread->wait_address != address;
|
||||||
});
|
});
|
||||||
|
@ -41,7 +41,7 @@ SharedPtr<Thread> AddressArbiter::ResumeHighestPriorityThread(VAddr address) {
|
||||||
// Determine which threads are waiting on this address, those should be considered for wakeup.
|
// Determine which threads are waiting on this address, those should be considered for wakeup.
|
||||||
auto matches_start = std::stable_partition(
|
auto matches_start = std::stable_partition(
|
||||||
waiting_threads.begin(), waiting_threads.end(), [address](const auto& thread) {
|
waiting_threads.begin(), waiting_threads.end(), [address](const auto& thread) {
|
||||||
ASSERT_MSG(thread->status == THREADSTATUS_WAIT_ARB,
|
ASSERT_MSG(thread->status == ThreadStatus::WaitArb,
|
||||||
"Inconsistent AddressArbiter state");
|
"Inconsistent AddressArbiter state");
|
||||||
return thread->wait_address != address;
|
return thread->wait_address != address;
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,7 +39,7 @@ SharedPtr<Event> HLERequestContext::SleepClientThread(SharedPtr<Thread> thread,
|
||||||
thread->wakeup_callback = [context = *this, callback](ThreadWakeupReason reason,
|
thread->wakeup_callback = [context = *this, callback](ThreadWakeupReason reason,
|
||||||
SharedPtr<Thread> thread,
|
SharedPtr<Thread> thread,
|
||||||
SharedPtr<WaitObject> object) mutable {
|
SharedPtr<WaitObject> object) mutable {
|
||||||
ASSERT(thread->status == THREADSTATUS_WAIT_HLE_EVENT);
|
ASSERT(thread->status == ThreadStatus::WaitHleEvent);
|
||||||
callback(thread, context, reason);
|
callback(thread, context, reason);
|
||||||
|
|
||||||
auto& process = thread->owner_process;
|
auto& process = thread->owner_process;
|
||||||
|
@ -56,7 +56,7 @@ SharedPtr<Event> HLERequestContext::SleepClientThread(SharedPtr<Thread> thread,
|
||||||
};
|
};
|
||||||
|
|
||||||
auto event = Kernel::Event::Create(Kernel::ResetType::OneShot, "HLE Pause Event: " + reason);
|
auto event = Kernel::Event::Create(Kernel::ResetType::OneShot, "HLE Pause Event: " + reason);
|
||||||
thread->status = THREADSTATUS_WAIT_HLE_EVENT;
|
thread->status = ThreadStatus::WaitHleEvent;
|
||||||
thread->wait_objects = {event};
|
thread->wait_objects = {event};
|
||||||
event->AddWaitingThread(thread);
|
event->AddWaitingThread(thread);
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ void Mutex::UpdatePriority() {
|
||||||
if (!holding_thread)
|
if (!holding_thread)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
u32 best_priority = THREADPRIO_LOWEST;
|
u32 best_priority = ThreadPrioLowest;
|
||||||
for (auto& waiter : GetWaitingThreads()) {
|
for (auto& waiter : GetWaitingThreads()) {
|
||||||
if (waiter->current_priority < best_priority)
|
if (waiter->current_priority < best_priority)
|
||||||
best_priority = waiter->current_priority;
|
best_priority = waiter->current_priority;
|
||||||
|
|
|
@ -69,10 +69,10 @@ ResultCode ServerSession::HandleSyncRequest(SharedPtr<Thread> thread) {
|
||||||
hle_handler->HandleSyncRequest(SharedPtr<ServerSession>(this));
|
hle_handler->HandleSyncRequest(SharedPtr<ServerSession>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thread->status == THREADSTATUS_RUNNING) {
|
if (thread->status == ThreadStatus::Running) {
|
||||||
// Put the thread to sleep until the server replies, it will be awoken in
|
// Put the thread to sleep until the server replies, it will be awoken in
|
||||||
// svcReplyAndReceive for LLE servers.
|
// svcReplyAndReceive for LLE servers.
|
||||||
thread->status = THREADSTATUS_WAIT_IPC;
|
thread->status = ThreadStatus::WaitIPC;
|
||||||
|
|
||||||
if (hle_handler != nullptr) {
|
if (hle_handler != nullptr) {
|
||||||
// For HLE services, we put the request threads to sleep for a short duration to
|
// For HLE services, we put the request threads to sleep for a short duration to
|
||||||
|
|
|
@ -161,8 +161,8 @@ static void ExitProcess() {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// TODO(Subv): When are the other running/ready threads terminated?
|
// TODO(Subv): When are the other running/ready threads terminated?
|
||||||
ASSERT_MSG(thread->status == THREADSTATUS_WAIT_SYNCH_ANY ||
|
ASSERT_MSG(thread->status == ThreadStatus::WaitSynchAny ||
|
||||||
thread->status == THREADSTATUS_WAIT_SYNCH_ALL,
|
thread->status == ThreadStatus::WaitSynchAll,
|
||||||
"Exiting processes with non-waiting threads is currently unimplemented");
|
"Exiting processes with non-waiting threads is currently unimplemented");
|
||||||
|
|
||||||
thread->Stop();
|
thread->Stop();
|
||||||
|
@ -283,14 +283,14 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
|
||||||
|
|
||||||
thread->wait_objects = {object};
|
thread->wait_objects = {object};
|
||||||
object->AddWaitingThread(thread);
|
object->AddWaitingThread(thread);
|
||||||
thread->status = THREADSTATUS_WAIT_SYNCH_ANY;
|
thread->status = ThreadStatus::WaitSynchAny;
|
||||||
|
|
||||||
// Create an event to wake the thread up after the specified nanosecond delay has passed
|
// Create an event to wake the thread up after the specified nanosecond delay has passed
|
||||||
thread->WakeAfterDelay(nano_seconds);
|
thread->WakeAfterDelay(nano_seconds);
|
||||||
|
|
||||||
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
||||||
SharedPtr<WaitObject> object) {
|
SharedPtr<WaitObject> object) {
|
||||||
ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY);
|
ASSERT(thread->status == ThreadStatus::WaitSynchAny);
|
||||||
|
|
||||||
if (reason == ThreadWakeupReason::Timeout) {
|
if (reason == ThreadWakeupReason::Timeout) {
|
||||||
thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
|
thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
|
||||||
|
@ -365,7 +365,7 @@ static ResultCode WaitSynchronizationN(s32* out, VAddr handles_address, s32 hand
|
||||||
return RESULT_TIMEOUT;
|
return RESULT_TIMEOUT;
|
||||||
|
|
||||||
// Put the thread to sleep
|
// Put the thread to sleep
|
||||||
thread->status = THREADSTATUS_WAIT_SYNCH_ALL;
|
thread->status = ThreadStatus::WaitSynchAll;
|
||||||
|
|
||||||
// Add the thread to each of the objects' waiting threads.
|
// Add the thread to each of the objects' waiting threads.
|
||||||
for (auto& object : objects) {
|
for (auto& object : objects) {
|
||||||
|
@ -379,7 +379,7 @@ static ResultCode WaitSynchronizationN(s32* out, VAddr handles_address, s32 hand
|
||||||
|
|
||||||
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
||||||
SharedPtr<WaitObject> object) {
|
SharedPtr<WaitObject> object) {
|
||||||
ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ALL);
|
ASSERT(thread->status == ThreadStatus::WaitSynchAll);
|
||||||
|
|
||||||
if (reason == ThreadWakeupReason::Timeout) {
|
if (reason == ThreadWakeupReason::Timeout) {
|
||||||
thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
|
thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
|
||||||
|
@ -421,7 +421,7 @@ static ResultCode WaitSynchronizationN(s32* out, VAddr handles_address, s32 hand
|
||||||
return RESULT_TIMEOUT;
|
return RESULT_TIMEOUT;
|
||||||
|
|
||||||
// Put the thread to sleep
|
// Put the thread to sleep
|
||||||
thread->status = THREADSTATUS_WAIT_SYNCH_ANY;
|
thread->status = ThreadStatus::WaitSynchAny;
|
||||||
|
|
||||||
// Add the thread to each of the objects' waiting threads.
|
// Add the thread to each of the objects' waiting threads.
|
||||||
for (std::size_t i = 0; i < objects.size(); ++i) {
|
for (std::size_t i = 0; i < objects.size(); ++i) {
|
||||||
|
@ -439,7 +439,7 @@ static ResultCode WaitSynchronizationN(s32* out, VAddr handles_address, s32 hand
|
||||||
|
|
||||||
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
||||||
SharedPtr<WaitObject> object) {
|
SharedPtr<WaitObject> object) {
|
||||||
ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY);
|
ASSERT(thread->status == ThreadStatus::WaitSynchAny);
|
||||||
|
|
||||||
if (reason == ThreadWakeupReason::Timeout) {
|
if (reason == ThreadWakeupReason::Timeout) {
|
||||||
thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
|
thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
|
||||||
|
@ -578,7 +578,7 @@ static ResultCode ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_
|
||||||
// No objects were ready to be acquired, prepare to suspend the thread.
|
// No objects were ready to be acquired, prepare to suspend the thread.
|
||||||
|
|
||||||
// Put the thread to sleep
|
// Put the thread to sleep
|
||||||
thread->status = THREADSTATUS_WAIT_SYNCH_ANY;
|
thread->status = ThreadStatus::WaitSynchAny;
|
||||||
|
|
||||||
// Add the thread to each of the objects' waiting threads.
|
// Add the thread to each of the objects' waiting threads.
|
||||||
for (std::size_t i = 0; i < objects.size(); ++i) {
|
for (std::size_t i = 0; i < objects.size(); ++i) {
|
||||||
|
@ -590,7 +590,7 @@ static ResultCode ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_
|
||||||
|
|
||||||
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
||||||
SharedPtr<WaitObject> object) {
|
SharedPtr<WaitObject> object) {
|
||||||
ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY);
|
ASSERT(thread->status == ThreadStatus::WaitSynchAny);
|
||||||
ASSERT(reason == ThreadWakeupReason::Signal);
|
ASSERT(reason == ThreadWakeupReason::Signal);
|
||||||
|
|
||||||
ResultCode result = RESULT_SUCCESS;
|
ResultCode result = RESULT_SUCCESS;
|
||||||
|
@ -729,7 +729,7 @@ static ResultCode CreateThread(Handle* out_handle, u32 priority, u32 entry_point
|
||||||
u32 stack_top, s32 processor_id) {
|
u32 stack_top, s32 processor_id) {
|
||||||
std::string name = fmt::format("thread-{:08X}", entry_point);
|
std::string name = fmt::format("thread-{:08X}", entry_point);
|
||||||
|
|
||||||
if (priority > THREADPRIO_LOWEST) {
|
if (priority > ThreadPrioLowest) {
|
||||||
return ERR_OUT_OF_RANGE;
|
return ERR_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -738,20 +738,20 @@ static ResultCode CreateThread(Handle* out_handle, u32 priority, u32 entry_point
|
||||||
return ERR_NOT_AUTHORIZED;
|
return ERR_NOT_AUTHORIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (processor_id == THREADPROCESSORID_DEFAULT) {
|
if (processor_id == ThreadProcessorIdDefault) {
|
||||||
// Set the target CPU to the one specified in the process' exheader.
|
// Set the target CPU to the one specified in the process' exheader.
|
||||||
processor_id = g_current_process->ideal_processor;
|
processor_id = g_current_process->ideal_processor;
|
||||||
ASSERT(processor_id != THREADPROCESSORID_DEFAULT);
|
ASSERT(processor_id != ThreadProcessorIdDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (processor_id) {
|
switch (processor_id) {
|
||||||
case THREADPROCESSORID_0:
|
case ThreadProcessorId0:
|
||||||
break;
|
break;
|
||||||
case THREADPROCESSORID_ALL:
|
case ThreadProcessorIdAll:
|
||||||
LOG_INFO(Kernel_SVC,
|
LOG_INFO(Kernel_SVC,
|
||||||
"Newly created thread is allowed to be run in any Core, unimplemented.");
|
"Newly created thread is allowed to be run in any Core, unimplemented.");
|
||||||
break;
|
break;
|
||||||
case THREADPROCESSORID_1:
|
case ThreadProcessorId1:
|
||||||
LOG_ERROR(Kernel_SVC,
|
LOG_ERROR(Kernel_SVC,
|
||||||
"Newly created thread must run in the SysCore (Core1), unimplemented.");
|
"Newly created thread must run in the SysCore (Core1), unimplemented.");
|
||||||
break;
|
break;
|
||||||
|
@ -800,7 +800,7 @@ static ResultCode GetThreadPriority(u32* priority, Handle handle) {
|
||||||
|
|
||||||
/// Sets the priority for the specified thread
|
/// Sets the priority for the specified thread
|
||||||
static ResultCode SetThreadPriority(Handle handle, u32 priority) {
|
static ResultCode SetThreadPriority(Handle handle, u32 priority) {
|
||||||
if (priority > THREADPRIO_LOWEST) {
|
if (priority > ThreadPrioLowest) {
|
||||||
return ERR_OUT_OF_RANGE;
|
return ERR_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace Kernel {
|
||||||
static CoreTiming::EventType* ThreadWakeupEventType = nullptr;
|
static CoreTiming::EventType* ThreadWakeupEventType = nullptr;
|
||||||
|
|
||||||
bool Thread::ShouldWait(Thread* thread) const {
|
bool Thread::ShouldWait(Thread* thread) const {
|
||||||
return status != THREADSTATUS_DEAD;
|
return status != ThreadStatus::Dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::Acquire(Thread* thread) {
|
void Thread::Acquire(Thread* thread) {
|
||||||
|
@ -45,7 +45,7 @@ static Kernel::HandleTable wakeup_callback_handle_table;
|
||||||
static std::vector<SharedPtr<Thread>> thread_list;
|
static std::vector<SharedPtr<Thread>> thread_list;
|
||||||
|
|
||||||
// Lists only ready thread ids.
|
// Lists only ready thread ids.
|
||||||
static Common::ThreadQueueList<Thread*, THREADPRIO_LOWEST + 1> ready_queue;
|
static Common::ThreadQueueList<Thread*, ThreadPrioLowest + 1> ready_queue;
|
||||||
|
|
||||||
static SharedPtr<Thread> current_thread;
|
static SharedPtr<Thread> current_thread;
|
||||||
|
|
||||||
|
@ -75,11 +75,11 @@ void Thread::Stop() {
|
||||||
|
|
||||||
// Clean up thread from ready queue
|
// Clean up thread from ready queue
|
||||||
// This is only needed when the thread is termintated forcefully (SVC TerminateProcess)
|
// This is only needed when the thread is termintated forcefully (SVC TerminateProcess)
|
||||||
if (status == THREADSTATUS_READY) {
|
if (status == ThreadStatus::Ready) {
|
||||||
ready_queue.remove(current_priority, this);
|
ready_queue.remove(current_priority, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
status = THREADSTATUS_DEAD;
|
status = ThreadStatus::Dead;
|
||||||
|
|
||||||
WakeupAllWaitingThreads();
|
WakeupAllWaitingThreads();
|
||||||
|
|
||||||
|
@ -111,17 +111,17 @@ static void SwitchContext(Thread* new_thread) {
|
||||||
previous_thread->last_running_ticks = CoreTiming::GetTicks();
|
previous_thread->last_running_ticks = CoreTiming::GetTicks();
|
||||||
Core::CPU().SaveContext(previous_thread->context);
|
Core::CPU().SaveContext(previous_thread->context);
|
||||||
|
|
||||||
if (previous_thread->status == THREADSTATUS_RUNNING) {
|
if (previous_thread->status == ThreadStatus::Running) {
|
||||||
// This is only the case when a reschedule is triggered without the current thread
|
// This is only the case when a reschedule is triggered without the current thread
|
||||||
// yielding execution (i.e. an event triggered, system core time-sliced, etc)
|
// yielding execution (i.e. an event triggered, system core time-sliced, etc)
|
||||||
ready_queue.push_front(previous_thread->current_priority, previous_thread);
|
ready_queue.push_front(previous_thread->current_priority, previous_thread);
|
||||||
previous_thread->status = THREADSTATUS_READY;
|
previous_thread->status = ThreadStatus::Ready;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load context of new thread
|
// Load context of new thread
|
||||||
if (new_thread) {
|
if (new_thread) {
|
||||||
ASSERT_MSG(new_thread->status == THREADSTATUS_READY,
|
ASSERT_MSG(new_thread->status == ThreadStatus::Ready,
|
||||||
"Thread must be ready to become running.");
|
"Thread must be ready to become running.");
|
||||||
|
|
||||||
// Cancel any outstanding wakeup events for this thread
|
// Cancel any outstanding wakeup events for this thread
|
||||||
|
@ -132,7 +132,7 @@ static void SwitchContext(Thread* new_thread) {
|
||||||
current_thread = new_thread;
|
current_thread = new_thread;
|
||||||
|
|
||||||
ready_queue.remove(new_thread->current_priority, new_thread);
|
ready_queue.remove(new_thread->current_priority, new_thread);
|
||||||
new_thread->status = THREADSTATUS_RUNNING;
|
new_thread->status = ThreadStatus::Running;
|
||||||
|
|
||||||
if (previous_process != current_thread->owner_process) {
|
if (previous_process != current_thread->owner_process) {
|
||||||
Kernel::g_current_process = current_thread->owner_process;
|
Kernel::g_current_process = current_thread->owner_process;
|
||||||
|
@ -156,7 +156,7 @@ static Thread* PopNextReadyThread() {
|
||||||
Thread* next;
|
Thread* next;
|
||||||
Thread* thread = GetCurrentThread();
|
Thread* thread = GetCurrentThread();
|
||||||
|
|
||||||
if (thread && thread->status == THREADSTATUS_RUNNING) {
|
if (thread && thread->status == ThreadStatus::Running) {
|
||||||
// We have to do better than the current thread.
|
// We have to do better than the current thread.
|
||||||
// This call returns null when that's not possible.
|
// This call returns null when that's not possible.
|
||||||
next = ready_queue.pop_first_better(thread->current_priority);
|
next = ready_queue.pop_first_better(thread->current_priority);
|
||||||
|
@ -173,7 +173,7 @@ static Thread* PopNextReadyThread() {
|
||||||
|
|
||||||
void WaitCurrentThread_Sleep() {
|
void WaitCurrentThread_Sleep() {
|
||||||
Thread* thread = GetCurrentThread();
|
Thread* thread = GetCurrentThread();
|
||||||
thread->status = THREADSTATUS_WAIT_SLEEP;
|
thread->status = ThreadStatus::WaitSleep;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExitCurrentThread() {
|
void ExitCurrentThread() {
|
||||||
|
@ -195,9 +195,9 @@ static void ThreadWakeupCallback(u64 thread_handle, s64 cycles_late) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thread->status == THREADSTATUS_WAIT_SYNCH_ANY ||
|
if (thread->status == ThreadStatus::WaitSynchAny ||
|
||||||
thread->status == THREADSTATUS_WAIT_SYNCH_ALL || thread->status == THREADSTATUS_WAIT_ARB ||
|
thread->status == ThreadStatus::WaitSynchAll || thread->status == ThreadStatus::WaitArb ||
|
||||||
thread->status == THREADSTATUS_WAIT_HLE_EVENT) {
|
thread->status == ThreadStatus::WaitHleEvent) {
|
||||||
|
|
||||||
// Invoke the wakeup callback before clearing the wait objects
|
// Invoke the wakeup callback before clearing the wait objects
|
||||||
if (thread->wakeup_callback)
|
if (thread->wakeup_callback)
|
||||||
|
@ -224,27 +224,27 @@ void Thread::ResumeFromWait() {
|
||||||
ASSERT_MSG(wait_objects.empty(), "Thread is waking up while waiting for objects");
|
ASSERT_MSG(wait_objects.empty(), "Thread is waking up while waiting for objects");
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case THREADSTATUS_WAIT_SYNCH_ALL:
|
case ThreadStatus::WaitSynchAll:
|
||||||
case THREADSTATUS_WAIT_SYNCH_ANY:
|
case ThreadStatus::WaitSynchAny:
|
||||||
case THREADSTATUS_WAIT_HLE_EVENT:
|
case ThreadStatus::WaitHleEvent:
|
||||||
case THREADSTATUS_WAIT_ARB:
|
case ThreadStatus::WaitArb:
|
||||||
case THREADSTATUS_WAIT_SLEEP:
|
case ThreadStatus::WaitSleep:
|
||||||
case THREADSTATUS_WAIT_IPC:
|
case ThreadStatus::WaitIPC:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case THREADSTATUS_READY:
|
case ThreadStatus::Ready:
|
||||||
// The thread's wakeup callback must have already been cleared when the thread was first
|
// The thread's wakeup callback must have already been cleared when the thread was first
|
||||||
// awoken.
|
// awoken.
|
||||||
ASSERT(wakeup_callback == nullptr);
|
ASSERT(wakeup_callback == nullptr);
|
||||||
// If the thread is waiting on multiple wait objects, it might be awoken more than once
|
// If the thread is waiting on multiple wait objects, it might be awoken more than once
|
||||||
// before actually resuming. We can ignore subsequent wakeups if the thread status has
|
// before actually resuming. We can ignore subsequent wakeups if the thread status has
|
||||||
// already been set to THREADSTATUS_READY.
|
// already been set to ThreadStatus::Ready.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case THREADSTATUS_RUNNING:
|
case ThreadStatus::Running:
|
||||||
DEBUG_ASSERT_MSG(false, "Thread with object id {} has already resumed.", GetObjectId());
|
DEBUG_ASSERT_MSG(false, "Thread with object id {} has already resumed.", GetObjectId());
|
||||||
return;
|
return;
|
||||||
case THREADSTATUS_DEAD:
|
case ThreadStatus::Dead:
|
||||||
// This should never happen, as threads must complete before being stopped.
|
// This should never happen, as threads must complete before being stopped.
|
||||||
DEBUG_ASSERT_MSG(false, "Thread with object id {} cannot be resumed because it's DEAD.",
|
DEBUG_ASSERT_MSG(false, "Thread with object id {} cannot be resumed because it's DEAD.",
|
||||||
GetObjectId());
|
GetObjectId());
|
||||||
|
@ -254,7 +254,7 @@ void Thread::ResumeFromWait() {
|
||||||
wakeup_callback = nullptr;
|
wakeup_callback = nullptr;
|
||||||
|
|
||||||
ready_queue.push_back(current_priority, this);
|
ready_queue.push_back(current_priority, this);
|
||||||
status = THREADSTATUS_READY;
|
status = ThreadStatus::Ready;
|
||||||
Core::System::GetInstance().PrepareReschedule();
|
Core::System::GetInstance().PrepareReschedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,12 +324,12 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
|
||||||
u32 arg, s32 processor_id, VAddr stack_top,
|
u32 arg, s32 processor_id, VAddr stack_top,
|
||||||
SharedPtr<Process> owner_process) {
|
SharedPtr<Process> owner_process) {
|
||||||
// Check if priority is in ranged. Lowest priority -> highest priority id.
|
// Check if priority is in ranged. Lowest priority -> highest priority id.
|
||||||
if (priority > THREADPRIO_LOWEST) {
|
if (priority > ThreadPrioLowest) {
|
||||||
LOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority);
|
LOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority);
|
||||||
return ERR_OUT_OF_RANGE;
|
return ERR_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (processor_id > THREADPROCESSORID_MAX) {
|
if (processor_id > ThreadProcessorIdMax) {
|
||||||
LOG_ERROR(Kernel_SVC, "Invalid processor id: {}", processor_id);
|
LOG_ERROR(Kernel_SVC, "Invalid processor id: {}", processor_id);
|
||||||
return ERR_OUT_OF_RANGE_KERNEL;
|
return ERR_OUT_OF_RANGE_KERNEL;
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
|
||||||
ready_queue.prepare(priority);
|
ready_queue.prepare(priority);
|
||||||
|
|
||||||
thread->thread_id = NewThreadId();
|
thread->thread_id = NewThreadId();
|
||||||
thread->status = THREADSTATUS_DORMANT;
|
thread->status = ThreadStatus::Dormant;
|
||||||
thread->entry_point = entry_point;
|
thread->entry_point = entry_point;
|
||||||
thread->stack_top = stack_top;
|
thread->stack_top = stack_top;
|
||||||
thread->nominal_priority = thread->current_priority = priority;
|
thread->nominal_priority = thread->current_priority = priority;
|
||||||
|
@ -408,16 +408,16 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
|
||||||
ResetThreadContext(thread->context, stack_top, entry_point, arg);
|
ResetThreadContext(thread->context, stack_top, entry_point, arg);
|
||||||
|
|
||||||
ready_queue.push_back(thread->current_priority, thread.get());
|
ready_queue.push_back(thread->current_priority, thread.get());
|
||||||
thread->status = THREADSTATUS_READY;
|
thread->status = ThreadStatus::Ready;
|
||||||
|
|
||||||
return MakeResult<SharedPtr<Thread>>(std::move(thread));
|
return MakeResult<SharedPtr<Thread>>(std::move(thread));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::SetPriority(u32 priority) {
|
void Thread::SetPriority(u32 priority) {
|
||||||
ASSERT_MSG(priority <= THREADPRIO_LOWEST && priority >= THREADPRIO_HIGHEST,
|
ASSERT_MSG(priority <= ThreadPrioLowest && priority >= ThreadPrioHighest,
|
||||||
"Invalid priority value.");
|
"Invalid priority value.");
|
||||||
// If thread was ready, adjust queues
|
// If thread was ready, adjust queues
|
||||||
if (status == THREADSTATUS_READY)
|
if (status == ThreadStatus::Ready)
|
||||||
ready_queue.move(this, current_priority, priority);
|
ready_queue.move(this, current_priority, priority);
|
||||||
else
|
else
|
||||||
ready_queue.prepare(priority);
|
ready_queue.prepare(priority);
|
||||||
|
@ -436,7 +436,7 @@ void Thread::UpdatePriority() {
|
||||||
|
|
||||||
void Thread::BoostPriority(u32 priority) {
|
void Thread::BoostPriority(u32 priority) {
|
||||||
// If thread was ready, adjust queues
|
// If thread was ready, adjust queues
|
||||||
if (status == THREADSTATUS_READY)
|
if (status == ThreadStatus::Ready)
|
||||||
ready_queue.move(this, current_priority, priority);
|
ready_queue.move(this, current_priority, priority);
|
||||||
else
|
else
|
||||||
ready_queue.prepare(priority);
|
ready_queue.prepare(priority);
|
||||||
|
|
|
@ -15,32 +15,37 @@
|
||||||
#include "core/hle/kernel/wait_object.h"
|
#include "core/hle/kernel/wait_object.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
|
class Mutex;
|
||||||
|
class Process;
|
||||||
|
|
||||||
enum ThreadPriority : u32 {
|
enum ThreadPriority : u32 {
|
||||||
THREADPRIO_HIGHEST = 0, ///< Highest thread priority
|
ThreadPrioHighest = 0, ///< Highest thread priority
|
||||||
THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps
|
ThreadPrioUserlandMax = 24, ///< Highest thread priority for userland apps
|
||||||
THREADPRIO_DEFAULT = 48, ///< Default thread priority for userland apps
|
ThreadPrioDefault = 48, ///< Default thread priority for userland apps
|
||||||
THREADPRIO_LOWEST = 63, ///< Lowest thread priority
|
ThreadPrioLowest = 63, ///< Lowest thread priority
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ThreadProcessorId : s32 {
|
enum ThreadProcessorId : s32 {
|
||||||
THREADPROCESSORID_DEFAULT = -2, ///< Run thread on default core specified by exheader
|
ThreadProcessorIdDefault = -2, ///< Run thread on default core specified by exheader
|
||||||
THREADPROCESSORID_ALL = -1, ///< Run thread on either core
|
ThreadProcessorIdAll = -1, ///< Run thread on either core
|
||||||
THREADPROCESSORID_0 = 0, ///< Run thread on core 0 (AppCore)
|
ThreadProcessorId0 = 0, ///< Run thread on core 0 (AppCore)
|
||||||
THREADPROCESSORID_1 = 1, ///< Run thread on core 1 (SysCore)
|
ThreadProcessorId1 = 1, ///< Run thread on core 1 (SysCore)
|
||||||
THREADPROCESSORID_MAX = 2, ///< Processor ID must be less than this
|
ThreadProcessorIdMax = 2, ///< Processor ID must be less than this
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ThreadStatus {
|
enum class ThreadStatus {
|
||||||
THREADSTATUS_RUNNING, ///< Currently running
|
Running, ///< Currently running
|
||||||
THREADSTATUS_READY, ///< Ready to run
|
Ready, ///< Ready to run
|
||||||
THREADSTATUS_WAIT_ARB, ///< Waiting on an address arbiter
|
WaitArb, ///< Waiting on an address arbiter
|
||||||
THREADSTATUS_WAIT_SLEEP, ///< Waiting due to a SleepThread SVC
|
WaitSleep, ///< Waiting due to a SleepThread SVC
|
||||||
THREADSTATUS_WAIT_IPC, ///< Waiting for the reply from an IPC request
|
WaitIPC, ///< Waiting for the reply from an IPC request
|
||||||
THREADSTATUS_WAIT_SYNCH_ANY, ///< Waiting due to WaitSynch1 or WaitSynchN with wait_all = false
|
WaitSynchAny, ///< Waiting due to WaitSynch1 or WaitSynchN with wait_all = false
|
||||||
THREADSTATUS_WAIT_SYNCH_ALL, ///< Waiting due to WaitSynchronizationN with wait_all = true
|
WaitSynchAll, ///< Waiting due to WaitSynchronizationN with wait_all = true
|
||||||
THREADSTATUS_WAIT_HLE_EVENT, ///< Waiting due to an HLE handler pausing the thread
|
WaitHleEvent, ///< Waiting due to an HLE handler pausing the thread
|
||||||
THREADSTATUS_DORMANT, ///< Created but not yet made ready
|
Dormant, ///< Created but not yet made ready
|
||||||
THREADSTATUS_DEAD ///< Run to completion, or forcefully terminated
|
Dead ///< Run to completion, or forcefully terminated
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ThreadWakeupReason {
|
enum class ThreadWakeupReason {
|
||||||
|
@ -48,11 +53,6 @@ enum class ThreadWakeupReason {
|
||||||
Timeout // The thread was woken up due to a wait timeout.
|
Timeout // The thread was woken up due to a wait timeout.
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Kernel {
|
|
||||||
|
|
||||||
class Mutex;
|
|
||||||
class Process;
|
|
||||||
|
|
||||||
class Thread final : public WaitObject {
|
class Thread final : public WaitObject {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -178,16 +178,16 @@ public:
|
||||||
* with wait_all = true.
|
* with wait_all = true.
|
||||||
*/
|
*/
|
||||||
bool IsSleepingOnWaitAll() const {
|
bool IsSleepingOnWaitAll() const {
|
||||||
return status == THREADSTATUS_WAIT_SYNCH_ALL;
|
return status == ThreadStatus::WaitSynchAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<ARM_Interface::ThreadContext> context;
|
std::unique_ptr<ARM_Interface::ThreadContext> context;
|
||||||
|
|
||||||
u32 thread_id;
|
u32 thread_id;
|
||||||
|
|
||||||
u32 status;
|
ThreadStatus status;
|
||||||
u32 entry_point;
|
VAddr entry_point;
|
||||||
u32 stack_top;
|
VAddr stack_top;
|
||||||
|
|
||||||
u32 nominal_priority; ///< Nominal thread priority, as set by the emulated application
|
u32 nominal_priority; ///< Nominal thread priority, as set by the emulated application
|
||||||
u32 current_priority; ///< Current thread priority, can be temporarily changed
|
u32 current_priority; ///< Current thread priority, can be temporarily changed
|
||||||
|
|
|
@ -34,13 +34,13 @@ void WaitObject::RemoveWaitingThread(Thread* thread) {
|
||||||
|
|
||||||
SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() {
|
SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() {
|
||||||
Thread* candidate = nullptr;
|
Thread* candidate = nullptr;
|
||||||
u32 candidate_priority = THREADPRIO_LOWEST + 1;
|
u32 candidate_priority = ThreadPrioLowest + 1;
|
||||||
|
|
||||||
for (const auto& thread : waiting_threads) {
|
for (const auto& thread : waiting_threads) {
|
||||||
// The list of waiting threads must not contain threads that are not waiting to be awakened.
|
// The list of waiting threads must not contain threads that are not waiting to be awakened.
|
||||||
ASSERT_MSG(thread->status == THREADSTATUS_WAIT_SYNCH_ANY ||
|
ASSERT_MSG(thread->status == ThreadStatus::WaitSynchAny ||
|
||||||
thread->status == THREADSTATUS_WAIT_SYNCH_ALL ||
|
thread->status == ThreadStatus::WaitSynchAll ||
|
||||||
thread->status == THREADSTATUS_WAIT_HLE_EVENT,
|
thread->status == ThreadStatus::WaitHleEvent,
|
||||||
"Inconsistent thread statuses in waiting_threads");
|
"Inconsistent thread statuses in waiting_threads");
|
||||||
|
|
||||||
if (thread->current_priority >= candidate_priority)
|
if (thread->current_priority >= candidate_priority)
|
||||||
|
@ -49,10 +49,10 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() {
|
||||||
if (ShouldWait(thread.get()))
|
if (ShouldWait(thread.get()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// A thread is ready to run if it's either in THREADSTATUS_WAIT_SYNCH_ANY or
|
// A thread is ready to run if it's either in ThreadStatus::WaitSynchAny or
|
||||||
// in THREADSTATUS_WAIT_SYNCH_ALL and the rest of the objects it is waiting on are ready.
|
// in ThreadStatus::WaitSynchAll and the rest of the objects it is waiting on are ready.
|
||||||
bool ready_to_run = true;
|
bool ready_to_run = true;
|
||||||
if (thread->status == THREADSTATUS_WAIT_SYNCH_ALL) {
|
if (thread->status == ThreadStatus::WaitSynchAll) {
|
||||||
ready_to_run = std::none_of(thread->wait_objects.begin(), thread->wait_objects.end(),
|
ready_to_run = std::none_of(thread->wait_objects.begin(), thread->wait_objects.end(),
|
||||||
[&thread](const SharedPtr<WaitObject>& object) {
|
[&thread](const SharedPtr<WaitObject>& object) {
|
||||||
return object->ShouldWait(thread.get());
|
return object->ShouldWait(thread.get());
|
||||||
|
|
|
@ -107,7 +107,7 @@ void File::Read(Kernel::HLERequestContext& ctx) {
|
||||||
std::chrono::nanoseconds read_timeout_ns{backend->GetReadDelayNs(length)};
|
std::chrono::nanoseconds read_timeout_ns{backend->GetReadDelayNs(length)};
|
||||||
ctx.SleepClientThread(Kernel::GetCurrentThread(), "file::read", read_timeout_ns,
|
ctx.SleepClientThread(Kernel::GetCurrentThread(), "file::read", read_timeout_ns,
|
||||||
[](Kernel::SharedPtr<Kernel::Thread> thread,
|
[](Kernel::SharedPtr<Kernel::Thread> thread,
|
||||||
Kernel::HLERequestContext& ctx, ThreadWakeupReason reason) {
|
Kernel::HLERequestContext& ctx, Kernel::ThreadWakeupReason reason) {
|
||||||
// Nothing to do here
|
// Nothing to do here
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1161,7 +1161,7 @@ void NWM_UDS::ConnectToNetwork(Kernel::HLERequestContext& ctx) {
|
||||||
connection_event = ctx.SleepClientThread(
|
connection_event = ctx.SleepClientThread(
|
||||||
Kernel::GetCurrentThread(), "uds::ConnectToNetwork", UDSConnectionTimeout,
|
Kernel::GetCurrentThread(), "uds::ConnectToNetwork", UDSConnectionTimeout,
|
||||||
[](Kernel::SharedPtr<Kernel::Thread> thread, Kernel::HLERequestContext& ctx,
|
[](Kernel::SharedPtr<Kernel::Thread> thread, Kernel::HLERequestContext& ctx,
|
||||||
ThreadWakeupReason reason) {
|
Kernel::ThreadWakeupReason reason) {
|
||||||
// TODO(B3N30): Add error handling for host full and timeout
|
// TODO(B3N30): Add error handling for host full and timeout
|
||||||
IPC::RequestBuilder rb(ctx, 0x1E, 1, 0);
|
IPC::RequestBuilder rb(ctx, 0x1E, 1, 0);
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
|
|
@ -198,11 +198,12 @@ void ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> server_ses
|
||||||
handler_invoker(this, info->handler_callback, context);
|
handler_invoker(this, info->handler_callback, context);
|
||||||
|
|
||||||
auto thread = Kernel::GetCurrentThread();
|
auto thread = Kernel::GetCurrentThread();
|
||||||
ASSERT(thread->status == THREADSTATUS_RUNNING || thread->status == THREADSTATUS_WAIT_HLE_EVENT);
|
ASSERT(thread->status == Kernel::ThreadStatus::Running ||
|
||||||
|
thread->status == Kernel::ThreadStatus::WaitHleEvent);
|
||||||
// Only write the response immediately if the thread is still running. If the HLE handler put
|
// Only write the response immediately if the thread is still running. If the HLE handler put
|
||||||
// the thread to sleep then the writing of the command buffer will be deferred to the wakeup
|
// the thread to sleep then the writing of the command buffer will be deferred to the wakeup
|
||||||
// callback.
|
// callback.
|
||||||
if (thread->status == THREADSTATUS_RUNNING) {
|
if (thread->status == Kernel::ThreadStatus::Running) {
|
||||||
context.WriteToOutgoingCommandBuffer(cmd_buf, *Kernel::g_current_process,
|
context.WriteToOutgoingCommandBuffer(cmd_buf, *Kernel::g_current_process,
|
||||||
Kernel::g_handle_table);
|
Kernel::g_handle_table);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,8 @@ void SRV::GetServiceHandle(Kernel::HLERequestContext& ctx) {
|
||||||
// TODO(yuriks): Permission checks go here
|
// TODO(yuriks): Permission checks go here
|
||||||
|
|
||||||
auto get_handle = [name, this](Kernel::SharedPtr<Kernel::Thread> thread,
|
auto get_handle = [name, this](Kernel::SharedPtr<Kernel::Thread> thread,
|
||||||
Kernel::HLERequestContext& ctx, ThreadWakeupReason reason) {
|
Kernel::HLERequestContext& ctx,
|
||||||
|
Kernel::ThreadWakeupReason reason) {
|
||||||
LOG_ERROR(Service_SRV, "called service={} wakeup", name);
|
LOG_ERROR(Service_SRV, "called service={} wakeup", name);
|
||||||
auto client_port = service_manager->GetServicePort(name);
|
auto client_port = service_manager->GetServicePort(name);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue