Threading and Processors?

BlitzMax Forums/BlitzMax Programming/Threading and Processors?

BLaBZ(Posted 2009) [#1]
Trying to figure this out....
Is this right?
When multi-threading is enabled, if you have multiple processors, BlitzMax will use them?


grable(Posted 2009) [#2]
No, YOU have to use Threads yourself. and the OS will (maybe) spread them around your cores.


Brucey(Posted 2009) [#3]
When multi-threading is enabled, if you have multiple processors, BlitzMax will use them?

Well, it's usually entirely up to the operating system to decide that, but generally, yes.

<EDIT>I just assumed you'd be employing threads as part of your question... Of course, if you simply compile your app with threading enabled but with no other changes, it will run as it would without threading enabled.


xlsior(Posted 2009) [#4]
When multi-threading is enabled, if you have multiple processors, BlitzMax will use them?


Yes, as long as you TELL your when/program where to launch seperate threads, and have them work together nicely. It won't magically spread your program across multiple CPU's on its own.


ImaginaryHuman(Posted 2009) [#5]
Basically, CPU's are not designed to work on more than one thing at a time (for the most part), which means that just as in the old days, one program runs on one cpu core. Rather than implement distribution of workload in hardware, you have to work around the separate between cpu cores by using software. That's what threads are for. You have to deliberately tell the cpu, effectively, which pieces of your program are `separate` enough to run elsewhere.


Winni(Posted 2009) [#6]
There's also a feature called 'thread affinity', which is used to bind a thread to a specific CPU. However, as far as I know, BlitzMax does not implement that, so you have to rely on the load balancing mechanisms of your operating system to distribute the threads across the available CPU cores.


QuickSilva(Posted 2009) [#7]
Are there any simple examples around that show off the threading features in an easy to understand way? I`m curious about looking into threads too. Are they pretty simple to implement?

Jason.


Arowx(Posted 2009) [#8]
See next thread down http://www.blitzbasic.com/Community/posts.php?topic=86318

and a more complex one here...

http://www.blitzbasic.com/Community/posts.php?topic=80119#903018

Couple of bugs in the second one so here's an update...



QuickSilva(Posted 2009) [#9]
Neat, thanks.

Jason.