[Linux/Threading] change self-suspend to wait to be resumed
This commit is contained in:
@@ -251,15 +251,19 @@ dword_result_t NtSuspendThread_entry(dword_t handle,
|
|||||||
(current_pcr->prcb_data.current_thread == thread->guest_object());
|
(current_pcr->prcb_data.current_thread == thread->guest_object());
|
||||||
|
|
||||||
if (is_self_suspend) {
|
if (is_self_suspend) {
|
||||||
// Self-suspension: just increment the suspend count and return
|
// Self-suspension: increment the suspend count and wait until
|
||||||
// The thread continues running - this matches Windows/Xbox behavior
|
// another thread resumes us (decrements count to 0)
|
||||||
auto guest_thread = thread->guest_object<X_KTHREAD>();
|
auto guest_thread = thread->guest_object<X_KTHREAD>();
|
||||||
suspend_count = guest_thread->suspend_count;
|
suspend_count = guest_thread->suspend_count;
|
||||||
guest_thread->suspend_count++;
|
guest_thread->suspend_count++;
|
||||||
result = X_STATUS_SUCCESS;
|
result = X_STATUS_SUCCESS;
|
||||||
XELOGD(
|
XELOGD("Thread {:X} self-suspending (count: {}) - waiting for resume",
|
||||||
"Thread {:X} self-suspending (count: {}) - continuing execution",
|
thread->handle(), guest_thread->suspend_count);
|
||||||
thread->handle(), guest_thread->suspend_count);
|
// Wait until suspend_count reaches 0 (resumed by another thread)
|
||||||
|
while (guest_thread->suspend_count > 0) {
|
||||||
|
xe::threading::Sleep(std::chrono::microseconds(100));
|
||||||
|
}
|
||||||
|
XELOGD("Thread {:X} resumed", thread->handle());
|
||||||
} else {
|
} else {
|
||||||
// Normal suspension of another thread
|
// Normal suspension of another thread
|
||||||
result = thread->Suspend(&suspend_count);
|
result = thread->Suspend(&suspend_count);
|
||||||
|
|||||||
Reference in New Issue
Block a user