⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

CgroupCpuController

Struct CgroupCpuController 

Source
pub struct CgroupCpuController {
    pub shares: u32,
    pub quota_us: u64,
    pub period_us: u64,
    pub burst_us: u64,
    pub stats: CpuBandwidthStats,
    pub throttled: bool,
    pub parent_id: u64,
    pub cgroup_id: u64,
    /* private fields */
}
Expand description

Cgroup CPU controller with shares and bandwidth limiting.

Fields§

§shares: u32

CPU shares (weight-based fair scheduling, default 1024).

§quota_us: u64

CPU quota in microseconds per period (0 = unlimited).

§period_us: u64

CPU period in microseconds (default 100000 = 100ms).

§burst_us: u64

Burst capacity in microseconds (0 = no burst).

§stats: CpuBandwidthStats

Bandwidth statistics.

§throttled: bool

Whether currently throttled.

§parent_id: u64

Parent cgroup ID for hierarchical distribution (0 = root).

§cgroup_id: u64

Unique cgroup ID.

Implementations§

Source§

impl CgroupCpuController

Source

pub fn new(cgroup_id: u64) -> Self

Source

pub fn set_shares(&mut self, shares: u32) -> Result<(), KernelError>

Set CPU shares (weight). Minimum 2, maximum 262144.

Source

pub fn set_bandwidth( &mut self, quota_us: u64, period_us: u64, ) -> Result<(), KernelError>

Set CPU bandwidth quota and period. quota_us=0 means unlimited. Period must be >= 1000us and <= 1000000us.

Source

pub fn set_burst(&mut self, burst_us: u64)

Set burst capacity in microseconds.

Source

pub fn consume_runtime(&mut self, ns: u64) -> bool

Consume runtime. Returns true if the task is now throttled.

Source

pub fn new_period(&mut self)

Begin a new scheduling period. Refills runtime and handles burst.

Source

pub fn effective_cpu_percent_x100(&self) -> u64

Calculate the effective CPU percentage (quota/period * 100). Returns percentage * 100 (fixed-point with 2 decimal digits). For example, quota=50000, period=100000 returns 5000 (50.00%).

Source

pub fn proportional_runtime_ns(&self, total_shares: u32) -> u64

Compute the weight-proportional share of CPU time for this cgroup relative to a total weight sum. Returns nanoseconds per period.

Trait Implementations§

Source§

impl Clone for CgroupCpuController

Source§

fn clone(&self) -> CgroupCpuController

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CgroupCpuController

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for CgroupCpuController

§

impl RefUnwindSafe for CgroupCpuController

§

impl Send for CgroupCpuController

§

impl Sync for CgroupCpuController

§

impl Unpin for CgroupCpuController

§

impl UnwindSafe for CgroupCpuController

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.