This commit is contained in:
2026-03-02 05:37:56 +00:00
parent 235d31e263
commit 1a8da28cfc
4 changed files with 124 additions and 1 deletions

73
Cargo.lock generated
View File

@@ -2,6 +2,79 @@
# It is not intended for manual editing.
version = 4
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "core_affinity"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a034b3a7b624016c6e13f5df875747cc25f884156aad2abd12b6c46797971342"
dependencies = [
"libc",
"num_cpus",
"winapi",
]
[[package]]
name = "hermit-abi"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c"
[[package]]
name = "libc"
version = "0.2.182"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112"
[[package]]
name = "lpmd-rewrite"
version = "0.1.0"
dependencies = [
"core_affinity",
"raw-cpuid",
]
[[package]]
name = "num_cpus"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b"
dependencies = [
"hermit-abi",
"libc",
]
[[package]]
name = "raw-cpuid"
version = "10.6.1"
source = "git+https://github.com/oxidecomputer/rust-cpuid.git#e86d96ba1e63a4c4ecfc521e9fc7a312db0e0c17"
dependencies = [
"bitflags",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View File

@@ -4,3 +4,5 @@ version = "0.1.0"
edition = "2024"
[dependencies]
core_affinity = "0.8.3"
raw-cpuid = { git = "https://github.com/oxidecomputer/rust-cpuid.git", version = "10.6.1" }

44
src/cpu.rs Normal file
View File

@@ -0,0 +1,44 @@
use std::{
collections::HashMap,
string,
sync::{Arc, Mutex},
};
use core_affinity::*;
use std::thread;
pub struct Cpu {
pub cores: HashMap<i32, CpuCore>,
}
struct CpuCore {}
enum CoreType {
P, // Performence
E, // Efficent
L, // Low power
}
impl Cpu {
pub fn new() -> Cpu {
let cpu = Arc::new(Mutex::new(Cpu {
cores: HashMap::new(),
}));
let _ = core_ids
.into_iter()
.map(|id| {
thread::spawn(move || {
// Pin this thread to a single CPU core.
let res = core_affinity::set_for_current(id);
if !res {
return;
}
})
})
.collect::<Vec<_>>();
for handle in handles.into_iter() {
handle.join().unwrap();
}
}
}

View File

@@ -1,4 +1,8 @@
use raw_cpuid::*;
mod cpu;
fn main() {
let a = cpuid!(26, 0);
println!("{:?}", a);
println!("Hello, world!");
meow
}