Threads on Saturn

RockinB

Established Member
Concerning ports of stuff that uses threads (like SDL), can we use threads on the Hitachi SH2 CPU of Saturn?
 
I guess it should be possible to have a thread running on each SH2, but I really don't know about multiple threads on the same CPU ...
 
My main concern is if there are certain CPU instructions necessary to implement thread support (and if so, does the SH2 have those instructions?).

I've read a little bit on the topic and it seems that User Level Threads should be possible using a threading library (libpthread, ...). Unfortunately ULT don't seem to support multiple processors, in opposite to Kernel Level Threads (done by OS).

As we have full controll, I guess dual CPU support could be hacked in.

Without having any potential CPU overhead in mind, threads could be our solution to use both CPUs efficiently. It would just be what I thought about earlier.

However, as for SDL there is no need for thread support, because the Dreamcast port does not use threading, for example.
 
Mmmh ... there isn't any multithreading instruction in the SH2. If you want to create a multithreaded library, you'll to do it from scratch at C level.

But that sounds like a good idea (if the execution doesn't kill the speed :p)

[edit] The SH2 execution looks pretty much like a thread : as soon it's started it loops waiting for the master SH2 FRT signal to be issued. When it's done, it then do some stuff and goes back to the waiting state when it's over ...
 
Back
Top