Yes, a process with more threads would get more CPU time than its competitors. A well-known case would be a maven compile, maven uses lots of CPU-intensive threads, hogging the system.
But, the current linux scheduler doesn't take only tasks into account, it also takes control groups in the cpu cgroup hierarchy into account. So, CPU time is divided between control groups, and then in each control group, CPU time is divided between tasks.
Since 2.6.38, Linux automatically puts taks into different cpu cgroups based on their session ids. This means that e.g: separate tabs in konsole/gnome-terminal get their own control group. So now your maven compilation is nicely isolated, and no longer hogs the system. See the descriptions at kernelnewbies and lwn.net.
Before 2.6.38 hit most systems, Lennart Poettering showed how to do it manually on a shell script at this LKML message.
I actually have a system where I run Eclipse and maven compiles, and the change from pre-2.6.38 to pre-2.6.38 + Lennart's cgroup binding (which I put on /etc/bashrc
and on my Eclipse launcher script) was just perfect. Maven no longer hogs the system (you wouldn't know there was a maven compile going on if it weren't for the CPU load monitor), and Eclipse now just hogs itself, not the rest of the system (I'll settle for that with Eclipse). Now I just need to update the kernel to one with better dirty-page writeback and that system will be a breeze to work on.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…