I am writing a program where there is a scope for 4 threads. I am using VC++ 6.0 & don't want to use any libraries only VC++. (By rule) optimal number of threads should be decided based on number of cores.
How to write code that creates different number of threads based on different number of cores ???
i want to follow following table
Cores | Threads
---------------
1 | 2
2 | 3
3+ | 4
There is 1 GUI & 3 worker threads. All worker threads use a circular buffer. I am thinking to implement 3 worker threads as follows.
- Read from File 2. Process the file 3. Create a new file after processing.
All these 3 steps are done sequentially for each single input file.
There will be a large number of files for processing (1000+)
I know how to detect cores. There can be if then else way also. But it seems it is going to be a difficult task to manage the code following 'if then else' way.
Is there any standard way to manage code under this situation.