devkitPro / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
14 stars 13 forks source link

[OGC] Fix priority of threads #32

Closed Quadraxis-v2 closed 9 months ago

Quadraxis-v2 commented 12 months ago

Description

SDL_CreateThread() calls SDL_SYS_CreateThread(), which in turn just calls LWP_CreateThread(&thread->handle, run_thread, args, 0, 0, 64), with 64 being the priority of the thread. It appears that 64 is also the priority of the main thread in libOGC. I don't know how the thread scheduler works (some insight would be appreciated), but the tie's effect is that spawned threads never yield back control of the CPU to the main thread until they finish. Lowering the priority of the new threads by 1 seems to restore concurrency, but maybe a different value would be more suitable.

WinterMute commented 9 months ago

Dropped the priority of background threads a bit more with https://github.com/devkitPro/SDL/commit/2352d0056ebff98c45903574f7042776076cf52d

The other commit on this PR seems to have already been PR'd & merged with https://github.com/devkitPro/SDL/commit/c57f0cdfa598ad690a4e0ec80bd926fb4304006d