[SDL] Multi-processor
Ryan C. Gordon
icculus at clutteredmind.org
Tue Aug 31 10:01:41 PDT 2004
> One more question. I don't see in the SDL API any function to connect
> a thread to a specific processor.
>
> Is that done automatically...?
All OSes that support multiple CPUs will put threads onto the least
loaded processor so that the work load is distributed. They will switch
them to new CPUs if needed (i.e. - two threads suddenly demand a lot of
CPU time on the same processor while another physical CPU is sitting
idle), but generally try not to, so that the CPU caches aren't wasted.
It's complicated to squeeze all the performance out of this that is
possible, but most OSes are smart about this behind the scenes.
This is true for Linux, Windows, FreeBSD, and MacOSX...I'm sure others,
like Solaris, do something similar.
Note that some OSes (Linux, BeOS, maybe others) can let you dictate what
thread goes to what physical CPU, and lets you command it to never
migrate between CPUs no matter what (they call this "processor
affinity"), but you can't do that via SDL, and generally, you shouldn't
do that anyhow...let the OS do the right thing for you. If you _must_
have this, you can skip SDL's threads and use the system calls directly,
but I'd recommend against this. If you use syscalls, you can't
(portably) use SDL_CreateThread and the mutex functions, etc (but the
rest of SDL is still available to you).
--ryan.
More information about the SDL
mailing list