mirror of
https://github.com/xenia-project/xenia.git
synced 2024-11-27 05:20:37 +00:00
Create XThread suspended and resume it when setup is complete. Fixes race condition on thread_ variable.
This commit is contained in:
parent
d01abd4694
commit
9a47082c88
@ -249,6 +249,8 @@ X_STATUS XThread::Create() {
|
||||
// Setup the thread state block (last error/etc).
|
||||
uint8_t* p = memory()->TranslateVirtual(guest_object());
|
||||
guest_thread->header.type = 6;
|
||||
guest_thread->suspend_count =
|
||||
(creation_params_.creation_flags & X_CREATE_SUSPENDED) ? 1 : 0;
|
||||
|
||||
xe::store_and_swap<uint32_t>(p + 0x010, guest_object() + 0x010);
|
||||
xe::store_and_swap<uint32_t>(p + 0x014, guest_object() + 0x010);
|
||||
@ -295,7 +297,7 @@ X_STATUS XThread::Create() {
|
||||
|
||||
xe::threading::Thread::CreationParameters params;
|
||||
params.stack_size = 16 * 1024 * 1024; // Ignore game, always big!
|
||||
params.create_suspended = (creation_params_.creation_flags & 0x1) == 0x1;
|
||||
params.create_suspended = true;
|
||||
thread_ = xe::threading::Thread::Create(params, [this]() {
|
||||
// Set name immediately, if we have one.
|
||||
thread_->set_name(name());
|
||||
@ -325,6 +327,11 @@ X_STATUS XThread::Create() {
|
||||
thread_->set_priority(creation_params_.creation_flags & 0x20 ? 1 : 0);
|
||||
}
|
||||
|
||||
if ((creation_params_.creation_flags & X_CREATE_SUSPENDED) == 0) {
|
||||
// Start the thread now that we're all setup.
|
||||
thread_->Resume();
|
||||
}
|
||||
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace kernel {
|
||||
class NativeList;
|
||||
class XEvent;
|
||||
|
||||
constexpr uint32_t X_CREATE_SUSPENDED = 0x00000004;
|
||||
constexpr uint32_t X_CREATE_SUSPENDED = 0x00000001;
|
||||
|
||||
constexpr uint32_t X_TLS_OUT_OF_INDEXES = UINT32_MAX;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user