目錄
- top
- top 詳解 及 使用
- top 常用的命令
- taskset
- taskset 的基本使用
- 1. 顯示某個行程(執行緒)運行所在的核
- 2. 設定某個行程(執行緒)運行的核
- taskset 的基本使用
top
主要用于查看 Linux系統中的所有行程

top 詳解 及 使用
上面的top
top - 04:27:03 up 6 days, 23:25, # top 系統運行時間
2 users, # 用戶個數
load average: 0.00, 0.00, 0.00 # 平均負載
Tasks: 258 total, 1 running, 257 sleeping, 0 stopped, 0 zombie
# 任務:總共258個,1個正在運行,257個睡眠,0個已停止,0個僵尸行程
%Cpu(s): 0.0 us, 1.6 sy, 0.0 ni, 98.4 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
# CPU使用率:用戶空間占用CPU百分比 內核空間占用CPU百分比 不知道 空閑CPU百分比 不知道了......
MiB Mem : 16008.3 total, 273.1 free, 10718.1 used, 5017.1 buff/cache
# 記憶體使用率: 總計 空閑 使用 快取
MiB Swap: 4096.0 total, 4094.5 free, 1.5 used. 4953.2 avail Mem
# 交換記憶體使用率: 總計 空閑 使用 可用記憶體
下面的top
PID USER PR NI VIRT RES
行程ID 行程所屬用戶 優先級 nice值 行程使用的虛擬記憶體總量,單位kb 行程使用的、未被換出的物理記憶體大小,單位kb,
SHR S
共享記憶體大小,單位kb 行程狀態 D:不可中斷的睡眠狀態 R:運行 S:睡眠 T:跟蹤/停止 Z:僵尸行程
%CPU %MEM TIME+ COMMAND
CPU占用百分比 記憶體占用百分比 行程使用的CPU時間總計,單位1/100秒 命令名
top 常用的命令
輸入 1 : 顯示所有 CPU 統計資訊
輸入 k ,會提示輸入行程ID,輸入ID后,可殺死對應行程
top -Hp PID :顯示當前行程所有的執行緒
taskset
主要用于查看 當前行程中的 所有執行緒
Show or change the CPU affinity of a process.
Options:
-a, --all-tasks operate on all the tasks (threads) for a given pid
-p, --pid operate on existing given pid
-c, --cpu-list display and specify cpus in list format
-h, --help display this help
-V, --version display version
The default behavior is to run a new command:
taskset 03 sshd -b 1024
You can retrieve the mask of an existing task: # 您可以檢索現有任務的掩碼:
taskset -p 700
Or set it: # 或者設定 (掩碼)
taskset -p 03 700
List format uses a comma-separated list instead of a mask: #
taskset -pc 0,3,7-11 700
Ranges in list format can take a stride argument:
e.g. 0-31:2 is equivalent to mask 0x55555555
taskset 的基本使用
1. 顯示某個行程(執行緒)運行所在的核
taskset -cp PID
2. 設定某個行程(執行緒)運行的核
啟動時設定 `taskset -c 0,10 ./bind_core`
運行中設定 `taskset -cp core PID` # core 可以為單個,或 串列 ,或 逗號分割
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/509395.html
標籤:Linux
下一篇:部署cobbler


