Xenomai
3.0.5
|
The Xenomai timer facility depends on a clock source (xnclock) for scheduling the next activation times. More...
Functions | |
void | xntimer_destroy (struct xntimer *timer) |
Release a timer object. More... | |
static xnticks_t | xntimer_interval (struct xntimer *timer) |
Return the timer interval value. More... | |
int | xntimer_start (struct xntimer *timer, xnticks_t value, xnticks_t interval, xntmode_t mode) |
Arm a timer. More... | |
xnticks_t | xntimer_get_date (struct xntimer *timer) |
Return the absolute expiration date. More... | |
static void | xntimer_stop (struct xntimer *timer) |
Disarm a timer. More... | |
static xnticks_t | xntimer_get_timeout (struct xntimer *timer) |
Return the relative expiration date. More... | |
void | xntimer_init (struct xntimer *timer, struct xnclock *clock, void(*handler)(struct xntimer *timer), struct xnsched *sched, int flags) |
Initialize a timer object. More... | |
void | __xntimer_migrate (struct xntimer *timer, struct xnsched *sched) |
Migrate a timer. More... | |
unsigned long long | xntimer_get_overruns (struct xntimer *timer, xnticks_t now) |
Get the count of overruns for the last tick. More... | |
static int | program_htick_shot (unsigned long delay, struct clock_event_device *cdev) |
Program next host tick as a Xenomai timer event. More... | |
static void | switch_htick_mode (enum clock_event_mode mode, struct clock_event_device *cdev) |
Tick mode switch emulation callback. More... | |
int | xntimer_grab_hardware (void) |
Grab the hardware timer on all real-time CPUs. More... | |
void | xntimer_release_hardware (void) |
Release hardware timers. More... | |
The Xenomai timer facility depends on a clock source (xnclock) for scheduling the next activation times.
The core provides and depends on a monotonic clock source (nkclock) with nanosecond resolution, driving the platform timer hardware exposed by the interrupt pipeline.
void __xntimer_migrate | ( | struct xntimer * | timer, |
struct xnsched * | sched | ||
) |
Migrate a timer.
This call migrates a timer to another cpu. In order to avoid pathological cases, it must be called from the CPU to which timer is currently attached.
timer | The address of the timer object to be migrated. |
sched | The address of the destination per-CPU scheduler slot. |
|
static |
Program next host tick as a Xenomai timer event.
Program the next shot for the host tick on the current CPU. Emulation is done using a nucleus timer attached to the master timebase.
delay | The time delta from the current date to the next tick, expressed as a count of nanoseconds. |
cdev | An pointer to the clock device which notifies us. |
|
static |
Tick mode switch emulation callback.
Changes the host tick mode for the tick device of the current CPU.
mode | The new mode to switch to. The possible values are: |
cdev | An opaque pointer to the clock device which notifies us. |
void xntimer_destroy | ( | struct xntimer * | timer | ) |
Release a timer object.
Destroys a timer. After it has been destroyed, all resources associated with the timer have been released. The timer is automatically deactivated before deletion if active on entry.
timer | The address of a valid timer descriptor. |
xnticks_t xntimer_get_date | ( | struct xntimer * | timer | ) |
Return the absolute expiration date.
Return the next expiration date of a timer as an absolute count of nanoseconds.
timer | The address of a valid timer descriptor. |
unsigned long long xntimer_get_overruns | ( | struct xntimer * | timer, |
xnticks_t | now | ||
) |
Get the count of overruns for the last tick.
This service returns the count of pending overruns for the last tick of a given timer, as measured by the difference between the expected expiry date of the timer and the date now passed as argument.
timer | The address of a valid timer descriptor. |
now | current date (as xnclock_read_raw(xntimer_clock(timer))) |
|
inlinestatic |
Return the relative expiration date.
This call returns the count of nanoseconds remaining until the timer expires.
timer | The address of a valid timer descriptor. |
int xntimer_grab_hardware | ( | void | ) |
Grab the hardware timer on all real-time CPUs.
xntimer_grab_hardware() grabs and tunes the hardware timer for all real-time CPUs.
Host tick emulation is performed for sharing the clock chip between Linux and Xenomai.
References xnsched::cpu, and xnintr_init().
void xntimer_init | ( | struct xntimer * | timer, |
struct xnclock * | clock, | ||
void(*)(struct xntimer *timer) | handler, | ||
struct xnsched * | sched, | ||
int | flags | ||
) |
Initialize a timer object.
Creates a timer. When created, a timer is left disarmed; it must be started using xntimer_start() in order to be activated.
timer | The address of a timer descriptor the nucleus will use to store the object-specific data. This descriptor must always be valid while the object is active therefore it must be allocated in permanent memory. |
clock | The clock the timer relates to. Xenomai defines a monotonic system clock, with nanosecond resolution, named nkclock. In addition, external clocks driven by other tick sources may be created dynamically if CONFIG_XENO_OPT_EXTCLOCK is defined. |
handler | The routine to call upon expiration of the timer. |
sched | An optional pointer to the per-CPU scheduler slot the new timer is affine to. If non-NULL, the timer will fire on the CPU sched is bound to, otherwise it will fire either on the current CPU if real-time, or on the first real-time CPU. |
flags | A set of flags describing the timer. The valid flags are: |
A set of clock gravity hints can be passed via the flags argument, used for optimizing the built-in heuristics aimed at latency reduction:
There is no limitation on the number of timers which can be created/active concurrently.
|
inlinestatic |
Return the timer interval value.
Return the timer interval value in nanoseconds.
timer | The address of a valid timer descriptor. |
void xntimer_release_hardware | ( | void | ) |
Release hardware timers.
Releases hardware timers previously grabbed by a call to xntimer_grab_hardware().
References xnsched::cpu.
int xntimer_start | ( | struct xntimer * | timer, |
xnticks_t | value, | ||
xnticks_t | interval, | ||
xntmode_t | mode | ||
) |
Arm a timer.
Activates a timer so that the associated timeout handler will be fired after each expiration time. A timer can be either periodic or one-shot, depending on the reload value passed to this routine. The given timer must have been previously initialized.
A timer is attached to the clock specified in xntimer_init().
timer | The address of a valid timer descriptor. |
value | The date of the initial timer shot, expressed in nanoseconds. |
interval | The reload value of the timer. It is a periodic interval value to be used for reprogramming the next timer shot, expressed in nanoseconds. If interval is equal to XN_INFINITE, the timer will not be reloaded after it has expired. |
mode | The timer mode. It can be XN_RELATIVE if value shall be interpreted as a relative date, XN_ABSOLUTE for an absolute date based on the monotonic clock of the related time base (as returned my xnclock_read_monotonic()), or XN_REALTIME if the absolute date is based on the adjustable real-time date for the relevant clock (obtained from xnclock_read_realtime()). |
|
inlinestatic |
Disarm a timer.
This service deactivates a timer previously armed using xntimer_start(). Once disarmed, the timer can be subsequently re-armed using the latter service.
timer | The address of a valid timer descriptor. |