Reputation: 493
Processes get CPU time as managed by the OS process scheduler. Since threads run in parallel within a single process, does this mean that a process's CPU time is further distributed(sliced) among threads? Or can the scheduler directly distribute CPU time among threads bypassing the parent process?
Upvotes: 0
Views: 172
Reputation: 13287
For Windows see http://msdn.microsoft.com/en-us/library/ms681917%28VS.85%29.aspx
Upvotes: 0
Reputation: 490118
I suspect the answer varies with the OS. On Windows, the process is not merely bypassed, but completely ignored -- all the scheduler deals with is threads. Processes are relevant only to the degree that all non-kernel threads do have to belong to some process, and every process has to contain at least one thread.
Upvotes: 3
Reputation: 23619
The threads are run/scheduled by the operating system and therefore they get their own CPU time. The process CPU time is just the sum of the CPU times of all the threads in the process.
If you want your process to schedule the tasks itself, you should use fibers (Windows). These are a kind of threads but they are not scheduled by the OS. The process should handle the scheduling of fibers itself.
Upvotes: 2