GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> PBS / V2-12-1 > pbs / rhel4-32


Interface   Data Structures   File List   Data Fields   Globals  

WUT.c File Reference

WakeUp Timer facility. More...

#include <PBS/WUT.h>
#include <PBS/WUT_tmr.h>
#include <PBS/TOV.h>
#include <PBS/FPA.h>
#include <PBS/MBA.h>
#include <PBS/Q.h>
#include <PBS/Q.ih>
#include <PBS/PTS.h>
#include <WCT_pvtdefs.h>
#include <PBI/PTR.h>
#include <WUT_debug.c>

Classes

struct  _WUT_keepalive_ctx
 Callback structure for the keepalive callbacks. More...
struct  _WUT_keepalive
 Captures the keepalive timer entry and context parameter. More...
struct  _WCB_common
 WakeUp Control Block. More...

Defines

#define WUT_DEBUG
 Used to include debugging code.
#define STATIC   static
 Kludge for Doxygen,.
#define MEMBER_OFFSET(_structure, _member)   ((int) &(((_structure *) 0) -> _member))
 Calculates the offset, in bytes, of the specified _member in _structure.
#define WUT_M_KEY   1
 WUT key used to allow some normally prohibited actions.

Typedefs

typedef struct _WUT_keepalive_ctx WUT_keepalive_ctx
 Typedef for WUT_keepalive_ctx.
typedef struct _WUT_keepalive WUT_keepalive
 Typedef for struct _WUT_keepalive.
typedef struct _WCB_common WCB_common
 Typedef for struct _WCB.
typedef struct _WCB WCB
 Typedef for struct _WCB.

Functions

STATIC WUT_tmradd_key (const WUT_tmr *wut)
 Adds an special key to the timer entry handle. Operations which are normally prohibited are allowed in special circumstances.
STATIC int has_key (const WUT_tmr *wut)
 Tests whether the WUT timer entry has the special key attached.
STATIC WUT_tmrremove_key (const WUT_tmr *wut)
 Removes the special key from a WUT timer entry.
STATIC WUT_tmrget_wut (const Q_node *node)
 Returns a pointer to top of the WUT timer structure.
STATIC WUT_state add_wut (WUT_tmr *wut, register TOV tov)
 Adds the specified WUT timer entry into the active que.
STATIC const Q_nodefind (const Q_head *que, register TOV tov)
 Scans the que to find the last timer entry with a timeout value smaller than tov.
STATIC int cmp_lt_tov (TOV tov_a, TOV tov_b)
 Platform implementation dependent routine to compare to timeout values.
STATIC int lock_que (WCB *wcb)
 Platform implementation dependent routine to lock the WUT timer que.
STATIC void unlock_que (WCB *wcb, int key)
 Platform implementation dependent routine to unlock the WUT timer que.
STATIC void arm_handler (WCB *wcb, TOV tov)
 Seeds the timer interrupt to handle expire a tov.
STATIC void arm_handler_nxt_wut (WCB *wcb, const WUT_tmr *wut)
 Seeds the timer interrupt to handle expire at the timeout associated with the specified WUT timer entry.
STATIC int wut_sys_connect (WCB *wcb)
 Platform dependent part of the WUT system connection process.
STATIC int wut_sys_shutdown (WCB *wcb)
 Platform dependent shutdown of the WUT system.
STATIC void wut_spc_init (WCB *wcb)
 Initializes the processor specific portion of the control block.
WUT_cb_status WUT_keepalive_rtn (WUT_keepalive_ctx *keepalive, WUT_tmr *wut)
 Simple WUT timer callback routine used to drive the VxWorks system clock.
WUT_cb_status WUT_keepalive_update (WUT_keepalive_ctx *keepalive, WUT_tmr *wut)
 Simple WUT timer callback routine used to update the WCT clock.
STATIC void init_wut (void *unused, WUT_tmr *wut, int pckt_size, int pcb_offset)
 Initializes each timer entry as it is added to the Free Packet Pool.
WUT_state WUT_cancel (WUT_tmr *wut)
 Cancels a WUT timer entry.
WUT_tmrWUT_create ()
 Allocate a WUT timer entry.
WUT_state WUT_destroy (WUT_tmr *wut)
 Destroys, ie frees, an unused WUT timer entry.
WUT_state WUT_expire (WUT_tmr *wut)
 Marks a wut timer as expire.
WUT_state WUT_restart (WUT_tmr *wut, register TOV tov)
 Restarts a WUT timer entry.
WUT_state WUT_start (WUT_tmr *wut, register TOV tov, WUT_cb_routine cb, void *prm)
 Establishes and starts a WUT timer entry.
WUT_state WUT_state_get (const WUT_tmr *wut)
 Gets the current state of the WUT timer entry.
TOV WUT_tov_get (const WUT_tmr *wut)
 Gets the current TOV of the WUT timer entry.
int WUT_overrun (const WUT_tmr *wut)
 Returns how 'on-time' the timer ISR was serviced.
unsigned int WUT_frequency ()
 Gets frequency, in Hertz of the WUT clock.
int WUT_sys_adjust (long long int dnsecx)
 Adjusts all the current entries on the WUT timer que in response to a change in the base time.
int WUT_sys_init (int count)
 One time WUT services initialization routine.
int WUT_sys_connect (unsigned int keepalive, unsigned int update)
 One time WUT connection routine to start WUT system.
int WUT_sys_reset (unsigned int keepalive, unsigned int update)
 Resets the keepalive and update times.
int WUT_sys_shutdown ()
 Shuts down the WUT routine.


Detailed Description

WakeUp Timer facility.

Author:
JJRussell - russell@slac.stanford.edu

   CVS $Id: WUT.c,v 1.14 2011/03/24 23:05:47 apw Exp $

Implementation file for the os/platform/compiler independent WUT routines. These routines provide the same style of functionality as the VxWorks 'wdb' routines, but with two important differences.

Define Documentation

#define MEMBER_OFFSET ( _structure,
_member   )     ((int) &(((_structure *) 0) -> _member))

Calculates the offset, in bytes, of the specified _member in _structure.

Parameters:
_structure The name or typedef of the structure
_member The member name
Returns:
The offset, in bytes, of the specified _member in _structure

Referenced by get_wut().

#define STATIC   static

Kludge for Doxygen,.

Doxygen does not like to float documentation for static functions across file boundaries. By defining a symbol for static, Doxygen no longer understands that the function is, in fact, static. Oh, the tangled WEB we weave.

#define WUT_M_KEY   1

WUT key used to allow some normally prohibited actions.

If this key is attached to the WUT timer handle, certain normally prohibited actions are allowed. In particular, one is allowed to DESTROY and REQUE WUT timer entries from the user callback routine. Note that this information cannot be carried with the state information, since all threads of execution would then have this priviledged status. One gets 'copy' semantics by attaching the key to the handle.

Referenced by add_key(), has_key(), and remove_key().


Typedef Documentation

WCB

Typedef for struct _WCB.

This structure contains all the control variables for the WakeUp Timer facility. It consists of a common or platform independent piece WCB_common and, optionally, a platform dependent piece.

Typedef for struct _WCB.

This structure contains all the control variables for the WakeUp Timer facility.

Typedef for struct _WUT_keepalive.

Simple WUT timer callback routine used as a periodic keepalive.

Parameters:
period Pointer to the period (in nanoseconds)
wut The WUT timer entry
Return values:
WUT_K_STATE_CHANGE_YES This is provided mainly for symmetry with the VxWorks implementation. In that implementation, this routine drives the system clock. In the POSIX implementation, it is just a periodic heartbeat.
The return value reflects the fact the timer entries state has been changed by the callback routine (its been restarted).

Typedef for WUT_keepalive_ctx.

Currently there are two styles of keepalive callbacks. The usual callback depends on an external source to update the WCT clock. The external source is likely the GPS 1 PPS signal or the on-board auxilliary realtime clocks.
The other style is the a keepalive that updates the WCT clock itself. This is a little incestuous, but is useful in low performance, debugging work.


Function Documentation

STATIC WUT_tmr * add_key ( const WUT_tmr wut  )  [inline]

Adds an special key to the timer entry handle. Operations which are normally prohibited are allowed in special circumstances.

Parameters:
wut The WUT timer entry to modify.
Returns:
The modified WUT timer entry.
This is an internal routine only.

References WUT_M_KEY.

Referenced by WUT_sys_handler().

STATIC WUT_state add_wut ( WUT_tmr wut,
register TOV  tov 
)

Adds the specified WUT timer entry into the active que.

Parameters:
wut The WUT timer entry to add
tov The timeout value.
Return values:
WUT_K_QUEUED 
This is an internal only routine. This routine scans the timer queue and places this entry before any other entries with a later timeout value. The active que is always ordered by timeout value, with the most quickly to expire at the top and the least at the bottom.

References arm_handler(), cmp_lt_tov(), _WCB::com, find(), _Q_node::flnk, get_wut(), lock_que(), _WUT_tmr::node, _Q_head::node, Q__insert(), Q__jam(), _WCB_common::que, _WUT_tmr::state, _WUT_tmr::tov, unlock_que(), Wcb, WUT_K_ACTIVE, and WUT_K_QUEUED.

Referenced by WUT_restart(), and WUT_start().

void arm_handler ( WCB wcb,
TOV  tov 
) [inline]

Seeds the timer interrupt to handle expire a tov.

Parameters:
wcb The WUT control block
tov The expiration timeout value

References BUG_check(), _WCB_qlt::cv, _WCB_specific::qlt, and _WCB::spc.

Referenced by add_wut().

void arm_handler_nxt_wut ( WCB wcb,
const WUT_tmr wut 
) [inline]

Seeds the timer interrupt to handle expire at the timeout associated with the specified WUT timer entry.

Parameters:
wcb The WUT control block
wut The WUT timer entry.

References BUG_check(), _WCB_qlt::cv, _WCB_specific::qlt, and _WCB::spc.

Referenced by WUT_cancel().

int cmp_lt_tov ( TOV  tov_a,
TOV  tov_b 
) [inline]

Platform implementation dependent routine to compare to timeout values.

Parameters:
tov_a The first of the two timeout values to compare
tov_b The second of the two timeout values to compare
Returns:
non-zero if tov_a < tov_b, else 0

References _TOV_u::tov, and _TOV_u::ts.

Referenced by add_wut(), find(), and WUT_sys_handler().

STATIC const Q_node * find ( const Q_head que,
register TOV  tov 
) [inline]

Scans the que to find the last timer entry with a timeout value smaller than tov.

Parameters:
que The active timer que to scan
tov The target expiration time
Returns:
The last timer entry with a timeout value smaller than tov.
This is an internal only routine.

References cmp_lt_tov(), _Q_node::flnk, get_wut(), _Q_head::node, and _WUT_tmr::tov.

Referenced by add_wut().

STATIC WUT_tmr * get_wut ( const Q_node node  )  [inline]

Returns a pointer to top of the WUT timer structure.

Parameters:
node The node (que links) of the WUT timer entry
This is an internal routine only. WUT timer entries are queued on both a free list and an active list. Because the que links are not at the top of the structure, but at some fixed offset from the top, a uniform method of paging to the top of WUT timer structure is provided.

References MEMBER_OFFSET.

Referenced by add_wut(), find(), WUT_cancel(), WUT_sys_adjust(), WUT_sys_handler(), and wut_sys_kill().

STATIC int has_key ( const WUT_tmr wut  )  [inline]

Tests whether the WUT timer entry has the special key attached.

Parameters:
wut The WUT timer entry to test.
Returns:
A non zero value if the special key is attached.
This is an internal routine only.

References WUT_M_KEY.

Referenced by WUT_cancel(), WUT_destroy(), WUT_expire(), WUT_restart(), and WUT_start().

STATIC void init_wut ( void *  unused,
WUT_tmr wut,
int  pckt_size,
int  pcb_offset 
)

Initializes each timer entry as it is added to the Free Packet Pool.

Parameters:
unused Unused parameter
wut The WUT timer entry to initialize
pckt_size The size of a packet
pcb_offset The offset to the FPA control structure
Initializes each timer entry as it is added to the WUT timer's free list.

References _WUT_tmr::state, and WUT_K_FREE.

Referenced by WUT_sys_init().

int lock_que ( WCB wcb  )  [inline]

Platform implementation dependent routine to lock the WUT timer que.

Parameters:
wcb Pointer to the WUT control block
Returns:
A key to be used to unlock the que.

References BUG_check(), _WCB_qlt::mutex, _WCB_specific::qlt, and _WCB::spc.

Referenced by add_wut(), WUT_cancel(), and wut_sys_kill().

STATIC WUT_tmr * remove_key ( const WUT_tmr wut  )  [inline]

Removes the special key from a WUT timer entry.

Parameters:
wut The WUT timer entry to remove the key from.
This is an internal routine only.

References WUT_M_KEY.

Referenced by WUT_cancel(), WUT_destroy(), WUT_expire(), WUT_keepalive_rtn(), WUT_restart(), WUT_start(), WUT_state_get(), and WUT_tov_get().

void unlock_que ( WCB wcb,
int  key 
) [inline]

Platform implementation dependent routine to unlock the WUT timer que.

Parameters:
wcb Pointer to the WUT control block
key The key used to unlock the que (returned from lock_que()

References BUG_check(), _WCB_qlt::mutex, _WCB_specific::qlt, and _WCB::spc.

Referenced by add_wut(), WUT_cancel(), and wut_sys_kill().

WUT_state WUT_cancel ( WUT_tmr wut  ) 

Cancels a WUT timer entry.

Parameters:
wut The WUT timer entry to cancel
Returns:
The new state. If successful this is WUT_K_CANCELLED
Cancels a WUT timer entry. Due to race conditions, this is a very tricky operation. Only timer entries in the WUT_K_QUEUED state may be cancelled. If the timer entry is not in this state, the cancel operation fails and the current state is returned to the user.

References arm_handler_nxt_wut(), _WCB::com, _Q_node::flnk, get_wut(), has_key(), lock_que(), _WUT_tmr::node, _Q_head::node, Q__unlink(), _WCB_common::que, remove_key(), _WUT_tmr::state, unlock_que(), Wcb, WUT_K_CANCELLED, and WUT_K_QUEUED.

WUT_tmr* WUT_create ( void   ) 

Allocate a WUT timer entry.

Returns:
If successful, a handle for WUT timer entry, else NULL
Allocates, without blocking a WUT timer entry. If successful, the state of the timer entry is updated to WUT_K_ALLOCATED.

References _WCB::com, _WCB_common::fcb, FPA_get(), _WUT_tmr::state, Wcb, and WUT_K_ALLOCATED.

WUT_state WUT_destroy ( WUT_tmr wut  ) 

Destroys, ie frees, an unused WUT timer entry.

Parameters:
wut The WUT timer entry to destroy
Returns:
If successful, WUT_K_FREE, else its current state.
A WUT timer entry can only be destroyed, ie returned to the free list, if it is in the state
  • WUT_K_ALLOCATED
  • WUT_K_CANCELLED
  • WUT_K_EXPIRED
  • or if it being destroyed as part of its ISR callback routine.

The user should ensure the timer entry was destroyed by checking that the returned state is WUT_K_FREE. Note that this value may also be returned if the timer entry was already in the the freed state.

References _WCB::com, _WCB_common::fcb, FPA_free(), has_key(), remove_key(), _WUT_tmr::state, Wcb, WUT_K_ALLOCATED, and WUT_K_FREE.

WUT_state WUT_expire ( WUT_tmr wut  ) 

Marks a wut timer as expire.

Parameters:
wut The WUT timer entry to expire
Returns:
IF successful, WUT_K_EXPIRED, else the current state
This routine must only be called from the user's callback routine. The user must call this, or one of WUT_cancel, WUT_start or WUT_restart in his callback before calling the routine being used to synchronize with another thread of execution. If successful, the WUT timer entry will be changed from the ACTIVE state to the EXPIRED state. Once in the EXPIRED state, ownership of the timer entry is effectively transferred from the WUT facility back to the user.
Warning:
This mechanism should be used instead of passing back WUT_K_STATE_CHANGED_YES or WUT_K_STATE_CHANGED_NO from the user's callback routine. This mechanism will continued to be honored and will work correctly on platforms where the WUT callback routine executes in a higher priority thread (for us VxWorks and not any of the host platforms. So to be portable and correct, use this call in lieu of the return code. The return code in portable code should now always be WUT_K_STATE_CHANGED_YES.

This call is necessary on platforms on POSIX platforms that do not support task priorities. On these platforms, the WUT timer cannot be protected by having the callback routine run in a higher priority thread. This means that WUT driver servicing the timer que cannot touch the WUT timer after the user's callback has been called. If this were allowed, there is a possibility that as soon as the user calls his synchronization routine, the thread waiting on that synchronization mechanism can begin execution. In that case, the user would make the reasonable assumption that the WUT timer handle is no longer property of the WUT facility. This call effectively declares to the WUT timer entry is no longer property of the WUT facility.

A previous implementation marked the timer entry EXPIRED after the return, thus allowing a hole between when the user called his synchronization method and when the driver marked it as inactive when the WUT timer was still property of the WUT facility. The user ownership assumption was thus violated.
Technically the previous implementation was protected since the state of the timer was still active, thus prohibiting operations on the timer. However, while technically correct, this implementation gave the user no good method (other than spinning) to know when the timer entry went to the expired state.

References has_key(), remove_key(), _WUT_tmr::state, and WUT_K_EXPIRED.

unsigned int WUT_frequency ( void   ) 

Gets frequency, in Hertz of the WUT clock.

Returns:
The frequency in Hertz of the WUT clock
In principle this allows the caller to translate physical time units, like nanoseconds, into the internal time units used by the WUT facility. However, this is only a crude conversion. For more accurate conversions the TOV facility should be used. One should consider this function as for informational purposes only.

References PTS_frequency().

WUT_cb_status WUT_keepalive_rtn ( WUT_keepalive_ctx keepalive,
WUT_tmr wut 
)

Simple WUT timer callback routine used to drive the VxWorks system clock.

Parameters:
keepalive The keepalive control structure.
wut The WUT timer entry
Return values:
WUT_K_STATE_CHANGE_YES 
VXWORKS Implementation Note
On the PowerPC platform, this routine is used to keep the decrement counter within its limited range, ensuring that no timer entry attempts to seed it with a value beyond it's limits. It is also used to update the VxWork's system clock by calling tickAnnounce().
Return Value
The return value reflects the fact the timer entries state has been changed by the callback routine (its been restarted).

References _WUT_keepalive_ctx::period, remove_key(), _WUT_tmr::tov, TOV_add_nsecx(), WUT_K_STATE_CHANGE_YES, and WUT_restart().

Referenced by WUT_sys_connect(), and WUT_sys_reset().

WUT_cb_status WUT_keepalive_update ( WUT_keepalive_ctx keepalive,
WUT_tmr wut 
)

Simple WUT timer callback routine used to update the WCT clock.

Parameters:
keepalive The keepalive control structure.
wut The WUT timer entry
Return values:
WUT_K_STATE_CHANGE_YES 
This routine is used in systems without an external clock, such as the sysAuxClock or the GPS.
The WUT timer entry updates the WCT clock and the timer entry is then requeued with the specified delay relative to it's previous expiration time. This creates a fairly accurate clock.
The return value reflects the fact the timer entries state has been changed by the callback routine (its been restarted).
VXWORKS IMPLEMENTATION NOTE
The VxWork's routine tickAnnounce(), is called to update the VxWork's system clock and WCT clock.

Referenced by WUT_sys_connect(), and WUT_sys_reset().

int WUT_overrun ( const WUT_tmr wut  ) 

Returns how 'on-time' the timer ISR was serviced.

Returns:
The current internal value of the WUT time
The caller may use this value to determine how 'on time' his callback routine was called. Remember, due to scheduling conflicts, the WUT facility may service the timer entry after its scheduled expiration time. It is up to the user to determine how late is 'too late'.

WUT_state WUT_restart ( WUT_tmr wut,
register TOV  tov 
)

Restarts a WUT timer entry.

Parameters:
wut The WUT timer entry to restart.
tov The timeout value.
Returns:
If successful, WUT_K_QUEUED
Restarts an timer entry. Only inactive timer entries, ie those in the state WUT_K_ALLOCATED, WUT_K_CANCELLED and WUT_K_EXPIRED may be restarted or WUT_restart is being called from the timer entries callback handler. If the state of the timer entry to be restarted is not one of these, the operation fails and WUT_restart() returns the state of the timer entry.

References add_wut(), has_key(), remove_key(), _WUT_tmr::state, and WUT_K_ALLOCATED.

Referenced by WUT_keepalive_rtn().

STATIC void wut_spc_init ( WCB wcb  ) 

Initializes the processor specific portion of the control block.

Parameters:
wcb The WUT control block

Referenced by WUT_sys_init().

WUT_state WUT_start ( WUT_tmr wut,
register TOV  tov,
WUT_cb_routine  cb,
void *  prm 
)

Establishes and starts a WUT timer entry.

Parameters:
wut The WUT timer entry to restart.
tov The timeout value
cb The address of the WUT timer entry's callback service routine.
prm A user parameter passed transparently through to the timer entry's callback service routine
Returns:
If successful, WUT_K_QUEUED
Places the WUT timer entry on the active queue. The timer entry to be started must be in one of the inactive states, ie WUT_K_ALLOCATED, WUT_K_CANCELLED or WUT_K_EXPIRED or it must own the special key, allowing it is to be started from the callback routine. If it is not in one of these conditions are true, the current state of the timer entry is returned.
The name is a bit of a misnomer, suggesting that this routine can only be called when the timer is initially place on the active que. Although it must be called to initially place the entry on the active que, this routine can be called to at any time (provided the state permits). When called in this fashion, it behaves very similarly to WUT_restart(). The difference is that this routine allows one to reset not only a new expiration time, but also the callback routine and callback parameter.
Used cleverly, this routine could be used to create a state machine which executes at prescribed times, and whose next expiration callback is handled by a different routine.

References add_wut(), _WUT_tmr::cb, has_key(), _WUT_tmr::prm, remove_key(), _WUT_tmr::state, and WUT_K_ALLOCATED.

Referenced by wut_sys_shutdown().

WUT_state WUT_state_get ( const WUT_tmr wut  ) 

Gets the current state of the WUT timer entry.

Parameters:
wut The WUT timer entry to get the state for.
Returns:
The current state of the WUT timer entry.
Simple query routine to return the current state of a timer entry.
Warning:
If the timer is in an active state or is shared amongst different threads, the state may not be static, ie it may change immediately after it is fetched. The user is responsible for using the results of this query wisely.

References remove_key(), and _WUT_tmr::state.

int WUT_sys_adjust ( long long int  dnsecx  ) 

Adjusts all the current entries on the WUT timer que in response to a change in the base time.

Returns:
The number of entries that were adjusted
Parameters:
dnsecx The number of nanoseconds to shift the timer que entries by.
This is a high level system routine used to fix-up the timer entries in response to a (hopefully) one-time resetting of the underlying system clock. The call to this routine will occur when the external time is known. Since this time is potentially well after the time WUT has started, it is necessary to adjust the entries on the WUT timer que to this new base time.
Warning:
There is a gotcha in this and that is that all timer que entries up to this point are assumed to be relative timers. It really does not make any sense to have placed any absolute timers on the que, since, until the external time is known, one has no basis for establishing when an absolute timer will expire.

It is assumed that interrupts are locked during the course of this execution.

References _WCB::com, _Q_node::flnk, get_wut(), _Q_head::node, _WCB_common::que, _WUT_tmr::tov, TOV_K_FOREVER, and Wcb.

int WUT_sys_connect ( unsigned int  keepalive,
unsigned int  update 
)

One time WUT connection routine to start WUT system.

Parameters:
keepalive The timeout period, in nsecs, to run the keepalive timer.
update The update period. If non-zero, the WCT clock will be updated at this rate. If 0, then WCT clock will be update externally.
Returns:
Status

References _WUT_tmr::cb, _WCB::com, _WUT_keepalive::ctx, _WUT_keepalive_ctx::elapsed, _WCB_common::keepalive, _WUT_tmr::node, _WUT_keepalive_ctx::period, _WUT_tmr::prm, Q_insert(), _WCB_common::que, _WUT_tmr::state, _WCB_common::terminator, _WUT_keepalive::tmr, _WUT_tmr::tov, TOV_from_nsecs(), TOV_K_FOREVER, _WUT_keepalive_ctx::update, Wcb, WUT_K_QUEUED, WUT_keepalive_rtn(), WUT_keepalive_update(), and wut_sys_connect().

Referenced by PBS_initialize2().

int wut_sys_connect ( WCB wcb  ) 

Platform dependent part of the WUT system connection process.

Parameters:
wcb The WUT control block
Returns:
Status

References _WCB_qlt::cv, _WCB_qlt::mutex, _WCB_specific::qlt, _WCB::spc, TASK_attr_init(), TASK_attr_priority_set(), TASK_spawn(), _WCB_specific::tcb, WUT_K_TASK_PRIORITY, and WUT_sys_handler().

Referenced by WUT_sys_connect().

int WUT_sys_init ( int  count  ) 

One time WUT services initialization routine.

Parameters:
count The number of available timer entries
Returns:
Status
Initializes a pool of WakeUp Timer entries. This is a one time system initialization call and establishes a fixed pool of timer entries. Enough timer entries should be configured to handle the maximum possible number of simoultaneosly outstanding requests. Timer entries are fairly cheap (~50 bytes) so one should allocate generously.
Having said that, the prudent programmer will allocate the timer entries he needs at his start-up time and hold on to them. While this is somewhat wasteful of system resources, it beats dealing with trying to allocate a timer entry during the meat of the code, only to come up empty handed. If this stategy is uniformily adopted it should be relatively easy to establish a working number.

References _WCB_common::cnt, _WCB::com, _WCB_common::fcb, FPA_fcb_sizeof(), FPA_init(), FPA_K_PCB_AT_EOP, FPA_K_TYPE_PENDING_FIFO, init_wut(), MBA_alloc(), Q_init(), _WCB_common::que, Wcb, and wut_spc_init().

Referenced by PBS_initialize2().

int WUT_sys_reset ( unsigned int  keepalive,
unsigned int  update 
)

Resets the keepalive and update times.

Returns:
Status
Parameters:
keepalive The timeout period, in nsecs, to run the keepalive timer. One values is recognized as special
  1. 0, Leave as is
  2. anything else, The new keepalive period
update The new update period (in nanoseconds). Three values are recognized
  1. -1, Remove the updater, the implication is that the caller is assuming responsibility for this function
  2. 0, Leave as is
  3. anything else, the new update time, in nanoseconds
This is used to establish new values for the keepalive and update timers. This is generally used after the initial initialization of the WUT facility, when one learns the absolute wall clock time.

References _WUT_tmr::cb, _WCB::com, _WUT_keepalive::ctx, _WCB_common::keepalive, _WUT_keepalive_ctx::period, _WUT_keepalive::tmr, _WUT_keepalive_ctx::update, Wcb, WUT_keepalive_rtn(), WUT_keepalive_update(), and wut_period_set().

int WUT_sys_shutdown ( void   ) 

Shuts down the WUT routine.

Returns:
Status, 1 indicates WUT was not started, so cannot be shutdown.
This is definitely a dicey function. It makes no check that the WUT que is empty. That is left to the poor user to guarantee.
Warning:
Given the degree of difficulty reclaiming all the resources, this function should probably be regarded as a debugging aid only. It can be used when reloading PBS>
If one does call it from a real piece of code, then the user is obligated to cancel any and all WUT timers. In addition, any timers allocated from the WUT pool should be returned. This last step is not strictly necessary. WUT knows where all its timer entries are so it will free them whether the user does or doesn't. Freeing the timers is just for clean-living.

References _WCB::com, _WCB_common::fcb, MBA_free(), Wcb, and wut_sys_shutdown().

Referenced by PBS_shutdown().

int wut_sys_shutdown ( WCB wcb  ) 

Platform dependent shutdown of the WUT system.

Parameters:
wcb The WUT control block
Returns:
Status

References _WCB::spc, TASK_join(), _WCB_specific::tcb, TOV_from_nsecs(), WUT_INIT, WUT_start(), and wut_sys_kill().

Referenced by WUT_sys_shutdown().

TOV WUT_tov_get ( const WUT_tmr wut  ) 

Gets the current TOV of the WUT timer entry.

Parameters:
wut The WUT timer entry to get the TOV for.
Returns:
The current TOV of the WUT timer entry.
Simply query routine to return the current state of a timer entry.
Warning:
If the timer is in an active state or is shared amongst different threads, the TOV may not be static, ie it may change immediately after it is fetched. The user is responsible for using the results of this query wisely.

References remove_key(), and _WUT_tmr::tov.


Generated on Sat Apr 9 18:27:08 2011 by  doxygen 1.5.8