Threading and Processors?
BlitzMax Forums/BlitzMax Programming/Threading and Processors?
| ||
Trying to figure this out.... Is this right? When multi-threading is enabled, if you have multiple processors, BlitzMax will use them? |
| ||
No, YOU have to use Threads yourself. and the OS will (maybe) spread them around your cores. |
| ||
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. |
| ||
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. |
| ||
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. |
| ||
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. |
| ||
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. |
| ||
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... |
| ||
Neat, thanks. Jason. |