3

From this question we know that both thread and process are treated as same schedule units in kernel and have little difference in scheduling scheme. However, I'm curious about the general cost of switching between threads and processes.

For example, when switching between 2 different processes, the kernel need to change the PTBR (in x86 is the CR3 Register) to switch process page table, causing the TLB to be re-flushed. But switching between different threads of same process seem to be free from such extra cost, since such threads should share the same virtual address space.

red0ct
  • 4,840
  • 3
  • 17
  • 44
choxsword
  • 3,187
  • 18
  • 44
  • Nobody knows what CPU you are using, how many cores, etc. The way to tell is to measure it. – stark Feb 21 '21 at 22:17
  • 1
    @stark do you mean that the performance is mainly architecture specific? But measuring such thing is not that easy, and there must be something architecture-irrelevant ,so I try to analyze it in theoretical perspective first. – choxsword Feb 22 '21 at 04:22
  • The biggest difference is likely to be CPU cache usage, which is arcitectural. – stark Feb 22 '21 at 11:42

0 Answers0