In the below example output, which columns detail the percent of time the CPU spent running non-kernel code and the percent of time the CPU spent running kernel code? (Choose TWO correct answers.)

# vmstat 1 100

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0      0 282120  134108 5797012  0    0     0     2    0    0  0  0 100 0
 0  0      0 282120  134108 5797012  0    0     0     2    0    0  0  0 100 0
 0  0      0 282120  134108 5797012  0    0     0     0 1007  359  0  0 100 0
 0  0      0 282120  134108 5797012  0    0     0     0 1117  577  0  0 100 0
 0  0      0 282120  134108 5797012  0    0     0     0 1007  366  0  0 100 0

A. id
B. us
C. wa
D. sy

题解

「vmstat」指令可以查看内存(由主内存和置换空间组合而成的虚拟内存)的状态。指令「vmstat 1 100」表示要以 1 秒钟的间隔来取 100 次内存的状态。

各个字段的意义如下:

  • r:运行中和等待中的进程数量。
  • b:处于不可中断睡眠状态(通常是在等待 I/O)的进程数量。
  • swpd:置换空间的使用量。(单位是 KiB)
  • free:闲置物理内存的量。(单位是 KiB)
  • buff:用来作为缓冲的内存的量。(单位是 KiB)
  • cache:用来作为缓存的内存的量。(单位是 KiB)
  • si:数据从硬盘置换进主内存的每秒数据量。(单位是 KiB)
  • so:数据从主内存置换进硬盘的每秒数据量。(单位是 KiB)
  • bi:从区块设备取得数据至内存中的每秒数据量。(单位是 KiB)
  • bo:将内存中的数据写进区块设备的每秒数据量。(单位是 KiB)
  • in:每秒的中断数量。
  • cs:每秒的上下文交换(context switch)数量。
  • us:运行非 Kernel 程序的时间。
  • sy:运行 Kernel 程序的时间。
  • id:闲置的时间。
  • wa:等待 IO 的时间。

所以答案是选项「B」和选项「D」。