Skip to content

Commit 10468ef

Browse files
committed
taskset: add CPU affinity tool
Implements taskset(1) with hex mask and CPU list parsing/formatting, -p (pid mode), -a (all-tasks), and exec mode. Includes stride notation in format_cpu_list, comma-separated hex mask support from /proc/<pid>/status, and unit + integration tests.
1 parent aab7822 commit 10468ef

9 files changed

Lines changed: 808 additions & 1 deletion

File tree

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ feat_common_core = [
4646
"rev",
4747
"setpgid",
4848
"setsid",
49+
"taskset",
4950
"uuidgen",
5051
]
5152

@@ -114,6 +115,7 @@ renice = { optional = true, version = "0.0.1", package = "uu_renice", path = "sr
114115
rev = { optional = true, version = "0.0.1", package = "uu_rev", path = "src/uu/rev" }
115116
setpgid = { optional = true, version = "0.0.1", package = "uu_setpgid", path = "src/uu/setpgid" }
116117
setsid = { optional = true, version = "0.0.1", package = "uu_setsid", path ="src/uu/setsid" }
118+
taskset = { optional = true, version = "0.0.1", package = "uu_taskset", path = "src/uu/taskset" }
117119
uuidgen = { optional = true, version = "0.0.1", package = "uu_uuidgen", path ="src/uu/uuidgen" }
118120

119121
[dev-dependencies]

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ First, reimplement the most important tools from util-linux:
5959
- `kill`: Sends signals to processes.
6060
- `renice`: Alters process priority.
6161
- `prlimit`: Sets/gets process resource limits.
62-
- `taskset`: Sets/gets process CPU affinity.
6362
- `uclampset`: Manages process utilization clamping.
63+
Done
64+
- `taskset`: Sets/gets process CPU affinity.
6465

6566
## User and Session Management
6667
- `su`: Changes user ID or becomes superuser.

src/uu/taskset/Cargo.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "uu_taskset"
3+
version = "0.0.1"
4+
edition = "2021"
5+
6+
[lib]
7+
path = "src/taskset.rs"
8+
9+
[[bin]]
10+
name = "taskset"
11+
path = "src/main.rs"
12+
13+
[dependencies]
14+
clap = { workspace = true }
15+
thiserror = { workspace = true }
16+
uucore = { workspace = true }
17+
18+
[target.'cfg(target_os = "linux")'.dependencies]
19+
nix = { workspace = true, features = ["sched"] }
20+
21+
[dev-dependencies]
22+
tempfile = { workspace = true }

src/uu/taskset/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uucore::bin!(uu_taskset);

0 commit comments

Comments
 (0)