[][src]Trait r3::kernel::PortTimer

pub trait PortTimer {
    pub const MAX_TICK_COUNT: UTicks;
    pub const MAX_TIMEOUT: UTicks;

    pub unsafe fn tick_count() -> UTicks;

    pub unsafe fn pend_tick_after(tick_count_delta: UTicks) { ... }
pub unsafe fn pend_tick() { ... } }

Implemented by a port. This trait contains items related to controlling a system timer.


These methods are only meant to be called by the kernel.

Associated Constants

pub const MAX_TICK_COUNT: UTicks[src]

The maximum value that tick_count can return. Must be greater than zero.

pub const MAX_TIMEOUT: UTicks[src]

The maximum value that can be passed to pend_tick_after. Must be greater than zero.

This value should be somewhat smaller than MAX_TICK_COUNT. The difference determines the kernel's resilience against overdue timer interrupts.

This is ignored and can take any value if pend_tick_after is implemented as no-op.

Loading content...

Required methods

pub unsafe fn tick_count() -> UTicks[src]

Read the current tick count (timer value).

This value steadily increases over time. When it goes past MAX_TICK_COUNT, it “wraps around” to 0.

The returned value must be in range 0..=MAX_TICK_COUNT.

Precondition: CPU Lock active

Loading content...

Provided methods

pub unsafe fn pend_tick_after(tick_count_delta: UTicks)[src]

Indicate that tick_count_delta ticks may elapse before the kernel should receive a call to PortToKernel::timer_tick.

tick_count_delta ticks” include the current (ongoing) tick. For example, tick_count_delta == 1 means timer_tick should be preferably called right after the next tick boundary.

The driver might track time in a coarser granularity than microseconds. In this case, the driver should wait until the earliest moment when tick_count() >= current_tick_count + tick_count_delta (where current_tick_count is the current value of tick_count(); not taking the wrap-around behavior into account) is fulfilled and call timer_tick.

It's legal to ignore the calls to this method entirely and call timer_tick at a steady rate, resulting in something similar to a “tickful” kernel. The default implementation does nothing assuming that the port driver is implemented in this way.

tick_count_delta must be in range 1..=MAX_TIMEOUT.

Precondition: CPU Lock active

pub unsafe fn pend_tick()[src]

Pend a call to PortToKernel::timer_tick as soon as possible.

The default implementation calls pend_tick_after(1).

Precondition: CPU Lock active

Loading content...


Loading content...