#cpu #free #core #processes

free-cpus

Get the set of free CPU cores on your Linux machine

2 stable releases

2.0.0 Oct 23, 2023
1.0.0 Oct 23, 2023

#1077 in Hardware support

MIT/Apache

7KB

free-cpus

Get the set of free CPU cores on your Linux machine.

The logic is heavily inspired by AFL++'s code.

Usage

Add to Cargo.toml:

[dependencies]
free-cpus = "2.0.0"

In your rust code:

// Get the set of free CPU cores on this Linux machine
let cpus: HashMap<usize> = free_cpus::get().unwrap();

lib.rs:

This crate exports a utility function that returns the set of available core IDs on the machine.

The set is determined by iterating over the /proc directory's process statuses. The logic is heavily inspired by AFL++'s code.

Dependencies

~210KB