展示 (或改变) 进程的 CPU 亲和度。
另请参阅: top
运行新命令 (默认行为) taskset 03 sshd -b 1024 检索现有任务的掩码 taskset -p 700 设置现有任务的掩码 taskset -p 03 700 列表格式使用逗号分隔而不是掩码: taskset -pc 0,3,7-11 700 列表格式范围可以采用 stride 自变量: 如 0-31:2 相当于掩码 0x55555555 只使用 CPU 核心 0 运行 python3 程序: taskset -c 0 python3 main.py 只使用 CPU 核心 0,1 运行 python3 程序: taskset -c 0,1 python3 main.py
基本语法
taskset [options] [mask | cpu-list] [pid|cmd [args...]]
Options 选项
| 参数 | EN 解释 | 中文翻译 | Remark |
|---|---|---|---|
| -a, --all-tasks | operate on all the tasks (threads) for a given pid | 操作给定 PID 的所有任务 (线程) | |
| -p, --pid | operate on existing given pid | 操作现有给定 PID | |
| -c, --cpu-list | display and specify cpus in list format | 以列表格式显示并指定 CPU | |
| -h, --help | display this help | 显示此帮助 | |
| -V, --version | output version information | 输出版本信息 |
| Function | 命令 | 文字解释 | 示例 | 示例解释 |
|---|---|---|---|---|
| Version | taskset -V | 展示版本信息 | ||
| taskset --version | ||||
| 帮助 | taskset -h | 展示帮助信息 | ||
| taskset --help |
Copyright Notice: This article is an exclusive original manuscript, copyright belongs to Happy Digits Software , shall not be reproduced without permission.