Merge pull request #3101 from Subv/hle_thread_pause2

Kernel/Threads: Add a new thread status that will allow using a Kernel::Event to put a guest thread to sleep inside an HLE handler until said event is signaled
This commit is contained in:
Weiyi Wang 2018-02-22 16:23:34 +02:00 committed by GitHub
commit 48512d9011
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 3 deletions

View file

@ -182,8 +182,16 @@ void ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> server_ses
LOG_TRACE(Service, "%s",
MakeFunctionString(info->name, GetServiceName().c_str(), cmd_buf).c_str());
handler_invoker(this, info->handler_callback, context);
context.WriteToOutgoingCommandBuffer(cmd_buf, *Kernel::g_current_process,
Kernel::g_handle_table);
auto thread = Kernel::GetCurrentThread();
ASSERT(thread->status == THREADSTATUS_RUNNING || thread->status == THREADSTATUS_WAIT_HLE_EVENT);
// 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
// callback.
if (thread->status == THREADSTATUS_RUNNING) {
context.WriteToOutgoingCommandBuffer(cmd_buf, *Kernel::g_current_process,
Kernel::g_handle_table);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////