Balanced load for threads?

BlitzMax Forums/BlitzMax Programming/Balanced load for threads?

ImaginaryHuman(Posted 2009) [#1]
Let's say you have just 2 treads running, one is probably doing something like loading image/audio/level data from disk, while the main thread is managing and updating a graphical menu.

What are the chances that the graphical update is going to remain smooth while the other thread is doing other activity? Should you try to only do `half as much` work? Will the framerate be able to stay constant?


ImaginaryHuman(Posted 2009) [#2]
Anyone had any experience in this area?


GfK(Posted 2009) [#3]
As I understand it, the process of loading data is only slow because of the hard drive access time. Any loading done on that thread shouldn't bother the CPU too much and certainly won't affect the GPU.

I may be completely wrong. Haven't got around to using any threads yet.


ziggy(Posted 2009) [#4]
What are the chances that the graphical update is going to remain smooth while the other thread is doing other activity?
On a double-core machine or even on a machine with hiperthreading, the chances are very high. Test it for yourself and be sure to not be consuming all the cpu time on one of the threads if the application is going to be run on core-solo machines. (time shared option)

Will the framerate be able to stay constant?
you can never be sure of this, even on a single thread, when running an application on a multitask OS. You better use delta timing in your graphics updating.

Should you try to only do `half as much` work?
Not. You should try to do as much as possible with every thread, but add some delay(0) at some point in one of the threads, just in case the app is going to be run on a core solo machine. This system sleeps on one thread are used sometimes to give processor time to other threades on non real multi thread environments. If your minimum machine is a PIV with hiperthreading, you can avoid the delay(0), but your app won't run very well on an atom.