mirror of
https://github.com/nasa/trick.git
synced 2024-12-22 06:27:49 +00:00
93 lines
2.7 KiB
Plaintext
93 lines
2.7 KiB
Plaintext
/**
|
|
|
|
@page LEVEL2 Sleep Timer Design
|
|
|
|
After all jobs in an execution frame have run, the default behavior (the timer is disabled)
|
|
is that the simulation will spin on the clock until real-time has caught up to simulation time.
|
|
Enabling the sleep timer gives control to the timer's pause() function, in which it may
|
|
release the processor and regain control when the timer elapses.
|
|
|
|
@section LEVEL3 Base Sleep Timer
|
|
|
|
The base Timer object provides a common interface for all Timers for the
|
|
following functions.
|
|
|
|
-# Enabling the Timer
|
|
-# Disabling the Timer
|
|
-# Getting the enabled/disabled status
|
|
|
|
The base Timer object provides an interface for the following operations. The
|
|
base Timer does not implement the following operations.
|
|
|
|
-# Initializing the Timer hardware
|
|
-# Setting the frame time for timer
|
|
-# Starting the timer
|
|
-# Resetting the timer
|
|
-# Pausing for the timer to expire
|
|
-# Stopping the timer
|
|
-# Shutting down the Timer hardware
|
|
|
|
@section LEVEL3 ITimer
|
|
|
|
The ITimer is a Timer object that derives from the the Base Sleep Timer. The
|
|
ITimer uses system itimer functionality to allow the simulation to release the
|
|
cpu while waiting for the timer to expire. When the itimer expires it uses
|
|
the SIGALRM signal to set a semaphore. When the semaphore is set the simulation
|
|
wakes up.
|
|
|
|
The itimer does not expire exactly at the desired period. It actually exipres after
|
|
the desired period by up to 1ms. To compensate for the delay we subtract 2ms from
|
|
the desired period. The RealtimeSync class "spins" on the clock the remaining
|
|
1-2ms the timer does not sleep for.
|
|
|
|
The ITimer implements the interface laid out by the base Timer class
|
|
|
|
@section LEVEL4 Initialization
|
|
|
|
@copydetails Trick::ITimer::init()
|
|
Trick::ITimer::init()
|
|
|
|
@section LEVEL4 Setting the Frame Time
|
|
|
|
@copydetails Trick::ITimer::set_frame_times()
|
|
Trick::ITimer::set_frame_times()
|
|
|
|
@section LEVEL4 Starting the timer.
|
|
|
|
@copydetails Trick::ITimer::start()
|
|
Trick::ITimer::start()
|
|
|
|
@section LEVEL4 Restarting the timer.
|
|
|
|
@copydetails Trick::ITimer::reset()
|
|
Trick::ITimer::reset()
|
|
|
|
@section LEVEL4 Pausing for the Timer to Expire
|
|
|
|
Pausing for the timer has 2 parts. The first is the signal handler that posts
|
|
a semaphore in response to a SIGALRM signal. The signal handler is assigned
|
|
to SIGALRM during the initialization routine. The second is the pause routine
|
|
that waits for the semaphore to be posted.
|
|
|
|
@section LEVEL5 Signal Handler
|
|
|
|
@copydetails Trick::ITimer::it_handler()
|
|
Trick::ITimer::it_handler()
|
|
|
|
@section LEVEL4 Pause for Semaphore
|
|
|
|
@copydetails Trick::ITimer::pause()
|
|
Trick::ITimer::pause()
|
|
|
|
@section LEVEL4 Stopping the timer.
|
|
|
|
@copydetails Trick::ITimer::stop()
|
|
Trick::ITimer::stop()
|
|
|
|
@section LEVEL4 Shutting Down the Timer
|
|
|
|
@copydetails Trick::ITimer::shutdown()
|
|
Trick::ITimer::shutdown()
|
|
|
|
*/
|