Skip to content

Commit

Permalink
wutstdc++: Use OSSetThreadRunQuantum in gthread implementation.
Browse files Browse the repository at this point in the history
To emulate pre-emptive scheduling which is what would be expected from
gthread.
  • Loading branch information
exjam committed Jan 18, 2020
1 parent a35269d commit d39e7ca
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libraries/wutstdc++/wut_gthread_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit d39e7ca

Please sign in to comment.