Do threads share time slot alloted to process
Do threads belongin开发者_如何学编程g to the same process share the time alloted to the process or the time alloted to the process depends on the number of threads in the process....i.e a time slot is alloted to each thread by CPU...???
A general answer doesn't exist since it depends on the policy adopted by any specific OS.
Three common choices are:
- 1 to 1, every thread has it's own schedulable entity
- N to 1, all threads of the same process aren't seen by the OS kernel, so just the whole process is scheduled (bad for multi-threading but good for legacy, they are somewhat similar to green threads)
- N to M, N threads are mapped to M schedulable entities (this is an hybrid approach that tries to be a compromise but it raises complexity of the scheduling)
More detailed explaination here.
For Windows, there's good documentation about how threads are selected to run here. Thread priority is a combination of per-process and per-thread information.
精彩评论