From d39e7cad4a1c69634a943f34cc0d2f69824a29fb Mon Sep 17 00:00:00 2001 From: James Benton Date: Sat, 18 Jan 2020 10:58:02 +0000 Subject: [PATCH] wutstdc++: Use OSSetThreadRunQuantum in gthread implementation. To emulate pre-emptive scheduling which is what would be expected from gthread. --- libraries/wutstdc++/wut_gthread_thread.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/wutstdc++/wut_gthread_thread.cpp b/libraries/wutstdc++/wut_gthread_thread.cpp index 93015b7..5cc0c83 100644 --- a/libraries/wutstdc++/wut_gthread_thread.cpp +++ b/libraries/wutstdc++/wut_gthread_thread.cpp @@ -43,6 +43,11 @@ __wut_thread_create(OSThread **outThread, *outThread = thread; OSSetThreadDeallocator(thread, &__wut_thread_deallocator); OSSetThreadCleanupCallback(thread, &__wut_thread_cleanup); + + // Set a thread run quantum to 1 millisecond, to force the threads to + // behave more like pre-emptive scheduling rather than co-operative. + OSSetThreadRunQuantum(thread, 1000); + OSResumeThread(thread); return 0; }