What is the overhead of a context-switch?

As wikipedia knows in its Context switch article, “context switch is the process of storing and restoring the state (context) of a process so that execution can be resumed from the same point at a later time.“. I’ll assume context switch between two processes of the same OS, not the user/kernel mode transition (syscall) which … Read more

simplest tool to measure C program cache hit/miss and cpu time in linux?

Use perf: perf stat ./yourapp See the kernel wiki perf tutorial for details. This uses the hardware performance counters of your CPU, so the overhead is very small. Example from the wiki: perf stat -B dd if=/dev/zero of=/dev/null count=1000000 Performance counter stats for ‘dd if=/dev/zero of=/dev/null count=1000000’: 5,099 cache-misses # 0.005 M/sec (scaled from 66.58%) … Read more