Skip to content

Commit

Permalink
FEXCore: Moves InternalThreadState ExecutionThread to the frontend
Browse files Browse the repository at this point in the history
Once again this is another frontend construct, so move it to
ThreadStateObject
  • Loading branch information
Sonicadvance1 committed Nov 29, 2024
1 parent f59fc0f commit 28180c9
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;
bool StartPaused {false};
InterruptableConditionVariable StartRunning;

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 @@ -664,7 +664,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 @@ -107,7 +107,7 @@ FEX::HLE::ThreadStateObject* CreateNewThread(FEXCore::Context::Context* CTX, FEX
Arg->CTX = CTX;
Arg->Thread = NewThread;
Arg->ThreadWaiting = &ThreadWaitingEvent;
NewThread->Thread->ExecutionThread = FEXCore::Threads::Thread::Create(ThreadHandler, Arg);
NewThread->ExecutionThread = FEXCore::Threads::Thread::Create(ThreadHandler, Arg);

// Wait for the thread to have started.
ThreadWaitingEvent.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 @@ -52,13 +52,13 @@ void ThreadManager::RunThread(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 28180c9

Please sign in to comment.