use alloc::format; use alloc::vec::Vec; use crate::{ percpu::get_all_stats, sync::CleanLockToken, syscall::error::{Error, Result, ENOENT}, }; /// Format one per-CPU stat line compatible with Linux `/proc/stat`: /// `user nice system idle iowait irq softirq steal`. /// /// Redox's scheduler tracks user, nice, kernel, idle, and irq. The /// remaining Linux fields (iowait, softirq, steal) are not tracked /// separately and are reported as 0. pub fn resource_for(cpu: u32, _token: &mut CleanLockToken) -> Result> { let stats = get_all_stats(); for (id, stat) in stats { if id.get() == cpu { let line = format!( "{} {} {} {} {} 0 0 0\n", stat.user, stat.nice, stat.kernel, stat.idle, stat.irq ); return Ok(line.into_bytes()); } } Err(Error::new(ENOENT)) }