1

I found several documents in stackoverflow with complex explanation mostly i don't understand. In simple term what is difference Process vs thread prioritization?

Rana
  • 389
  • 5
  • 17

1 Answers1

0

TL;DR - A simple answer is that there is no difference between a cgroup process and thread, but it is complex for multi-core systems due to migration.


The mechanics to set the thread priority versus the process priority is different from user space. Increase thread priority. The accounting and scheduling are generally the same after the priority is set.

As a goal, the scheduling of process versus thread is equal. Ie, there is no difference according to the goals.

In a simplifying move, Linux turns process scheduling into thread scheduling by treating a scheduled process as if it were single-threaded. If a process is multi-threaded with N threads, then N scheduling actions would be required to cover the threads. Threads within a multi-threaded process remain related in that they share resources such as memory address space. Linux threads are sometimes described as lightweight processes, with the lightweight underscoring the sharing of resources among the threads within a process. opensource.com

...but the hardware complicates this. Technologies like Hyperthreading will make it more efficient to keep threads on the same core. The layout of L1, L2, TLB, etc shared among cores on hardware prefers that threads are kept on the same CPU islands. This negates cache flushing and other effects. cgroups was implemented to keep related processes together. For instance auto-cgroup launched from the same TTY will share similar shared libraries and I/O and pipe from one process to another will benefit from data being in the cache when we move from the generating process to the consuming process.

Because threads have tighter coupling it is far less likely that they will migrate between cores independantly. Processes that do not share a cgroup are more likely to migrate to an idle core, so it is possible that they may end up getting more CPU, due to the asymmetry of work performed on different cores due to access to hardware resources. The configuration of 'server' versus 'desktop', or scheduling latency can also have an effect. It is possible that power management might also come into play. Ie, Does the code keep a core sleeping or wake it for process migration? And of course, the particular kernel version will have an effect as well as these noted high level configuration options.

References

artless noise
  • 21,212
  • 6
  • 68
  • 105