我正在研究 Linux 内核的工作原理,并对内核中发生的任何事情的时间尺度感兴趣。
当然我知道这取决于硬件,但想得到一个例子。例如,
- 中断服务例程:~1ms?
- 系统调用:~10ms?
- Printf(输出1个字符):20ms?(完全不确定)
如果有人可以留下任何评论或推荐包含上述信息的网站,我们将不胜感激。
答案1
也许您正在寻找顶部。
时间+列显示进程的 cpu 使用时间。
top - 13:33:24 up 2 days, 21:28, 7 users, load average: 0.27, 0.95, 0.92
Tasks: 733 total, 19 running, 691 sleeping, 0 stopped, 23 zombie
%Cpu(s): 18.4 us, 24.5 sy, 57.1 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 16287248 total, 15047664 used, 1239584 free, 144600 buffers
KiB Swap: 37457960 total, 6876096 used, 30581864 free, 5184516 cached
PID USER PR NI S %CPU %MEM TIME+ COMMAND
1 root 20 0 S 0.0 0.0 1037:17 init
2 root 20 0 S 0.0 0.0 0:00.03 kthreadd
3 root 20 0 S 0.0 0.0 45:34.38 ksoftirqd/0
5 root 0 -20 S 0.0 0.0 0:00.00 kworker/0:0H
7 root 0 -20 S 0.0 0.0 0:00.00 kworker/u:0H
8 root rt 0 S 0.0 0.0 0:17.35 migration/0
9 root 20 0 S 0.0 0.0 6:52.03 rcu_preempt
10 root 20 0 S 0.0 0.0 0:00.00 rcu_bh
11 root 20 0 S 0.0 0.0 0:00.00 rcu_sched
12 root rt 0 S 0.0 0.0 0:00.46 watchdog/0
13 root rt 0 S 0.0 0.0 0:00.47 watchdog/1
14 root 20 0 S 8.4 0.0 22:22.00 ksoftirqd/1
15 root rt 0 S 0.0 0.0 0:19.23 migration/1
18 root rt 0 S 0.0 0.0 0:00.48 watchdog/2
19 root 20 0 S 0.0 0.0 21:09.37 ksoftirqd/2
20 root rt 0 S 0.0 0.0 0:19.26 migration/2
22 root 0 -20 S 0.0 0.0 0:00.00 kworker/2:0H
23 root rt 0 S 0.0 0.0 0:00.50 watchdog/3
24 root 20 0 R 0.0 0.0 23:53.19 ksoftirqd/3
25 root rt 0 S 0.0 0.0 0:20.26 migration/3
27 root 0 -20 S 0.0 0.0 0:00.00 kworker/3:0H
28 root 0 -20 S 0.0 0.0 0:00.00 cpuset