Time Counter (TSC) when switching between Kernel & User mode

I am wondering if anyone will find out more information about the Linux timestamp counter when switching contexts? So far, I have been of the opinion that the TSC value only increases by 1 during each measure, regardless if in the kernel or in user mode. Now I measured the performance of the application using TSC, which gave the result of 5 Mio Clock Cyles performance. Then I made some changes to the scheduler, which means that the context switch takes much longer, i.e. 2 Mio cycles instead of 500,000 cycles. The funny bit is that when measuring the performance of the original application, it still takes 5 Mio cycles ... Therefore, I wonder why it didn’t take much more time,since almost 2 Mio clock cyles are now left in the context switch? (and at least 3 contexts exist at runtime).

Is the time stamp counter deactivated during kernel mode? Or are the contents of the TSC saved during the competition? Thanks if someone can tell me what might be the problem!

+3
source share
2 answers

How can you read Wikipedia

/ , "" TSC . : () . . , . - , BIOS, ​​( ). , . Intel TSC ( constant_tsc Linux/proc/cpuinfo). TSC . , , , . , , , .

+1

, TSC - , . IE: TSC RDTSC. , , reset.

, , , ? sched_yield() sleep(0) , , .

0

Source: https://habr.com/ru/post/1708092/


All Articles