Skip to content

Commit

Permalink
Merge pull request #4183 from Sonicadvance1/move_fexcore_executionthread
Browse files Browse the repository at this point in the history
FEXCore: Moves InternalThreadState ExecutionThread to the frontend
  • Loading branch information
Sonicadvance1 authored Nov 29, 2024
2 parents e89f48f + 802eaee commit 95d5b14
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion FEXCore/include/FEXCore/Debug/InternalThreadState.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ struct InternalThreadState : public FEXCore::Allocator::FEXAllocOperators {

FEXCore::Context::Context* const CTX;

NonMovableUniquePtr<FEXCore::Threads::Thread> ExecutionThread;

NonMovableUniquePtr<FEXCore::IR::OpDispatchBuilder> OpDispatcher;

Expand Down
2 changes: 1 addition & 1 deletion Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ uint64_t CloneHandler(FEXCore::Core::CpuStateFrame* Frame, FEX::HLE::clone3_args

if (flags & CLONE_VFORK) {
// If VFORK is set then the calling process is suspended until the thread exits with execve or exit
NewThread->Thread->ExecutionThread->join(nullptr);
NewThread->ExecutionThread->join(nullptr);

// Normally a thread cleans itself up on exit. But because we need to join, we are now responsible
FEX::HLE::_SyscallHandler->TM.DestroyThread(NewThread);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ FEX::HLE::ThreadStateObject* CreateNewThread(FEXCore::Context::Context* CTX, FEX
.CTX = CTX,
.Thread = NewThread,
};
NewThread->Thread->ExecutionThread = FEXCore::Threads::Thread::Create(ThreadHandler, &Arg);
NewThread->ExecutionThread = FEXCore::Threads::Thread::Create(ThreadHandler, &Arg);

// Wait for the thread to have started.
Arg.ThreadWaiting.Wait();
Expand Down
10 changes: 5 additions & 5 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/ThreadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ void ThreadManager::StopThread(FEX::HLE::ThreadStateObject* Thread) {
}

void ThreadManager::HandleThreadDeletion(FEX::HLE::ThreadStateObject* Thread, bool NeedsTLSUninstall) {
if (Thread->Thread->ExecutionThread) {
if (Thread->Thread->ExecutionThread->joinable()) {
Thread->Thread->ExecutionThread->join(nullptr);
if (Thread->ExecutionThread) {
if (Thread->ExecutionThread->joinable()) {
Thread->ExecutionThread->join(nullptr);
}

if (Thread->Thread->ExecutionThread->IsSelf()) {
Thread->Thread->ExecutionThread->detach();
if (Thread->ExecutionThread->IsSelf()) {
Thread->ExecutionThread->detach();
}
}

Expand Down
2 changes: 2 additions & 0 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/ThreadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ struct ThreadStateObject : public FEXCore::Allocator::FEXAllocOperators {
// personality emulation.
uint32_t persona {};

FEXCore::Core::NonMovableUniquePtr<FEXCore::Threads::Thread> ExecutionThread;

// Thread signaling information
std::atomic<SignalEvent> SignalReason {SignalEvent::Nothing};

Expand Down

0 comments on commit 95d5b14

Please sign in to comment.