Hi Mārtiņš, thank you for the detailed reply! I think I should have provided a more concrete example relating to my situation.
I'm referring to the first type of thread usage that you mention - those for real time processing that must be completed within a specific time requirement. The application I'm working on has a multi-instrument, multi voice, multi channel audio chain, so the processing requirements for the audio are quite high compared with the graphics, where most of the processing can be off-loaded to the GPU.
So, I'm processing my audio and graphics in the following way:
Relating to the above example, would it be better to have a dedicated audio thread pool with say 4 threads for audio processing jobs, and then a separate dedicated graphics pool of 2 threads for tasks such as physics calculations etc, object position updates etc? Or would it be better to have a general purpose shared pool of all 6 threads that either the graphics or the audio uses when tasks are required to be processed?
I can hypothesize several advantages and disadvantages for each solution:
- Fluctuations in processing requirements can be appropriately handled. I.e, more threads can be thrown at intense audio sections, and vice versa for graphics.
- Easier to respond to different hardware configurations? Especially for platforms that support a wide range of physical cores.
- Context switching probably really bad for CPU cache usage?
- Better i-cache and d-cache usage?
- Easier to manage? Easier to profile sub thread usage.
- Harder to configure based on platform/physical available cores?
- Ideally, the audio and graphics processing requirements should be relatively consistent anyway. Unpredictable fluctuations could lead to frame drops and audio stuttering.
I'm only really guessing here, however. The only way for me to really know is to try both configurations, but I wanted to see if someone had some experience with a situation like this.
Thank you for the links too, there's some good reading and watching there, I'm sure they will provide a great deal of insight.