\hypertarget{WUT_8h}{
\section{WUT.h File Reference}
\label{WUT_8h}\index{WUT.h@{WUT.h}}
}
Wake\-Up Timer, high resolution interrupt timers, function prototypes and public data structures. 

{\tt \#include \char`\"{}PBS/TOV.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/WUT\_\-cb.h\char`\"{}}\par


Include dependency graph for WUT.h:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=232pt]{WUT_8h__incl}
\end{center}
\end{figure}


This graph shows which files directly or indirectly include this file:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=327pt]{WUT_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define \hyperlink{WUT_8h_a0}{WUT\_\-INIT}(\_\-wut)~(\_\-wut) $\rightarrow$ state = WUT\_\-K\_\-ALLOCATED
\begin{CompactList}\small\item\em Initializes a user allocated timer for use. \item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
typedef enum \hyperlink{WUT_8h_a23}{\_\-WUT\_\-state} \hyperlink{WUT_8h_a1}{WUT\_\-state}
\begin{CompactList}\small\item\em Typedef for enum \_\-WUT\_\-state. \item\end{CompactList}\end{CompactItemize}
\subsection*{Enumerations}
\begin{CompactItemize}
\item 
enum \hyperlink{WUT_8h_a23}{\_\-WUT\_\-state} \{ \par
\hyperlink{WUT_8h_a23a2}{WUT\_\-K\_\-FREE} =  -2, 
\par
\hyperlink{WUT_8h_a23a3}{WUT\_\-K\_\-ACTIVE} =  -1, 
\par
\hyperlink{WUT_8h_a23a4}{WUT\_\-K\_\-QUEUED} =  0, 
\par
\hyperlink{WUT_8h_a23a5}{WUT\_\-K\_\-ALLOCATED} =  1, 
\par
\hyperlink{WUT_8h_a23a6}{WUT\_\-K\_\-CANCELLED} =  2, 
\par
\hyperlink{WUT_8h_a23a7}{WUT\_\-K\_\-EXPIRED} =  3
 \}
\begin{CompactList}\small\item\em Enumerate the possible states of a Wake\-Up Timer entry. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
int \hyperlink{WUT_8h_a8}{WUT\_\-sys\_\-adjust} (long long int dnsecx)
\begin{CompactList}\small\item\em Adjusts all the current entries on the WUT timer que in response to a change in the base time. \item\end{CompactList}\item 
int \hyperlink{WUT_8h_a9}{WUT\_\-sys\_\-init} (int count)
\begin{CompactList}\small\item\em One time WUT services initialization routine. \item\end{CompactList}\item 
int \hyperlink{WUT_8h_a10}{WUT\_\-sys\_\-connect} (unsigned int keepalive, unsigned int update)
\begin{CompactList}\small\item\em One time WUT connection routine to start WUT system. \item\end{CompactList}\item 
int \hyperlink{WUT_8h_a11}{WUT\_\-sys\_\-reset} (unsigned int keepalive, unsigned int update)
\begin{CompactList}\small\item\em Resets the keepalive and update times. \item\end{CompactList}\item 
int \hyperlink{WUT_8h_a12}{WUT\_\-sys\_\-shutdown} (void)
\begin{CompactList}\small\item\em Shuts down the WUT routine. \item\end{CompactList}\item 
\hyperlink{WUT_8h_a1}{WUT\_\-state} \hyperlink{WUT_8h_a13}{WUT\_\-cancel} (\hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$wut)
\begin{CompactList}\small\item\em Cancels a WUT timer entry. \item\end{CompactList}\item 
\hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$ \hyperlink{WUT_8h_a14}{WUT\_\-create} (void)
\begin{CompactList}\small\item\em Allocate a WUT timer entry. \item\end{CompactList}\item 
\hyperlink{WUT_8h_a1}{WUT\_\-state} \hyperlink{WUT_8h_a15}{WUT\_\-expire} (\hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$wut)
\begin{CompactList}\small\item\em Marks a wut timer as expire. \item\end{CompactList}\item 
\hyperlink{WUT_8h_a1}{WUT\_\-state} \hyperlink{WUT_8h_a16}{WUT\_\-destroy} (\hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$wut)
\begin{CompactList}\small\item\em Destroys, ie frees, an unused WUT timer entry. \item\end{CompactList}\item 
\hyperlink{WUT_8h_a1}{WUT\_\-state} \hyperlink{WUT_8h_a17}{WUT\_\-restart} (\hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$wut, register \hyperlink{TOV_8h_8px-xxx-xxx_a8}{TOV} tov)
\begin{CompactList}\small\item\em Restarts a WUT timer entry. \item\end{CompactList}\item 
\hyperlink{WUT_8h_a1}{WUT\_\-state} \hyperlink{WUT_8h_a18}{WUT\_\-start} (\hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$wut, register \hyperlink{TOV_8h_8px-xxx-xxx_a8}{TOV} tov, \hyperlink{WUT__cb_8h_a1}{WUT\_\-cb\_\-routine} cb, void $\ast$prm)
\begin{CompactList}\small\item\em Establishes and starts a WUT timer entry. \item\end{CompactList}\item 
\hyperlink{WUT_8h_a1}{WUT\_\-state} \hyperlink{WUT_8h_a19}{WUT\_\-state\_\-get} (const \hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$wut)
\begin{CompactList}\small\item\em Gets the current state of the WUT timer entry. \item\end{CompactList}\item 
\hyperlink{TOV_8h_8px-xxx-xxx_a8}{TOV} \hyperlink{WUT_8h_a20}{WUT\_\-tov\_\-get} (const \hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$wut)
\begin{CompactList}\small\item\em Gets the current TOV of the WUT timer entry. \item\end{CompactList}\item 
int \hyperlink{WUT_8h_a21}{WUT\_\-dec\_\-get} (void)
\begin{CompactList}\small\item\em Gets the current time left till the next timer expiration. \item\end{CompactList}\item 
unsigned int \hyperlink{WUT_8h_a22}{WUT\_\-frequency} (void)
\begin{CompactList}\small\item\em Gets frequency, in Hertz of the WUT clock. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Wake\-Up Timer, high resolution interrupt timers, function prototypes and public data structures. 

\begin{Desc}
\item[Author:]JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}


\footnotesize\begin{verbatim}   CVS $Id: WUT.h,v 1.7 2005/10/01 01:00:12 russell Exp $
\end{verbatim}
\normalsize


Interface file for the Wake\-Up Timer interrupt facility.

\subsection{Define Documentation}
\hypertarget{WUT_8h_a0}{
\index{WUT.h@{WUT.h}!WUT_INIT@{WUT\_\-INIT}}
\index{WUT_INIT@{WUT\_\-INIT}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-INIT]{\setlength{\rightskip}{0pt plus 5cm}\#define WUT\_\-INIT(\_\-wut)~(\_\-wut) $\rightarrow$ state = WUT\_\-K\_\-ALLOCATED}}
\label{WUT_8h_a0}


Initializes a user allocated timer for use. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-wut}]A pointer to the user timer to initialize\end{description}
\end{Desc}
If a WUT timer is allocated in another way besides calling WUT\_\-create, the timer must be initialized for use by calling this macro.

\subsection{Typedef Documentation}
\hypertarget{WUT_8h_a1}{
\index{WUT.h@{WUT.h}!WUT_state@{WUT\_\-state}}
\index{WUT_state@{WUT\_\-state}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-state]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{WUT_8h_a1}{WUT\_\-state}}}
\label{WUT_8h_a1}


Typedef for enum \_\-WUT\_\-state. 

The ownership of a timer handle is divided into two pieces.

When the value of the state is $>$= WUT\_\-K\_\-ALLOCATED, the user has ownership of the WUT timer handle. When the user has ownership of the WUT timer handle, it's state will not change except by user request. The user is allowed to request state changes, for example, by WUT\_\-cancel, but there is no guarantee that these state changes will be granted.

When the value of the state is $<$ WUT\_\-K\_\-ALLOCATED, the WUT services have ownership of the WUT handle. When the WUT services have ownership, the state may spontaneously change due to WUT activity.

\subsection{Enumeration Type Documentation}
\hypertarget{WUT_8h_a23}{
\index{WUT.h@{WUT.h}!_WUT_state@{\_\-WUT\_\-state}}
\index{_WUT_state@{\_\-WUT\_\-state}!WUT.h@{WUT.h}}
\subsubsection[\_\-WUT\_\-state]{\setlength{\rightskip}{0pt plus 5cm}enum \hyperlink{WUT_8h_a23}{\_\-WUT\_\-state}}}
\label{WUT_8h_a23}


Enumerate the possible states of a Wake\-Up Timer entry. 

\begin{Desc}
\item[Enumerator: ]\par
\begin{description}
\index{WUT_K_FREE@{WUT\_\-K\_\-FREE}!WUT.h@{WUT.h}}\index{WUT.h@{WUT.h}!WUT_K_FREE@{WUT\_\-K\_\-FREE}}\item[{\em 
\hypertarget{WUT_8h_a23a2}{
WUT\_\-K\_\-FREE}
\label{WUT_8h_a23a2}
}]It's back in the pool \index{WUT_K_ACTIVE@{WUT\_\-K\_\-ACTIVE}!WUT.h@{WUT.h}}\index{WUT.h@{WUT.h}!WUT_K_ACTIVE@{WUT\_\-K\_\-ACTIVE}}\item[{\em 
\hypertarget{WUT_8h_a23a3}{
WUT\_\-K\_\-ACTIVE}
\label{WUT_8h_a23a3}
}]It's being serviced \index{WUT_K_QUEUED@{WUT\_\-K\_\-QUEUED}!WUT.h@{WUT.h}}\index{WUT.h@{WUT.h}!WUT_K_QUEUED@{WUT\_\-K\_\-QUEUED}}\item[{\em 
\hypertarget{WUT_8h_a23a4}{
WUT\_\-K\_\-QUEUED}
\label{WUT_8h_a23a4}
}]On the active queue \index{WUT_K_ALLOCATED@{WUT\_\-K\_\-ALLOCATED}!WUT.h@{WUT.h}}\index{WUT.h@{WUT.h}!WUT_K_ALLOCATED@{WUT\_\-K\_\-ALLOCATED}}\item[{\em 
\hypertarget{WUT_8h_a23a5}{
WUT\_\-K\_\-ALLOCATED}
\label{WUT_8h_a23a5}
}]It's been allocated \index{WUT_K_CANCELLED@{WUT\_\-K\_\-CANCELLED}!WUT.h@{WUT.h}}\index{WUT.h@{WUT.h}!WUT_K_CANCELLED@{WUT\_\-K\_\-CANCELLED}}\item[{\em 
\hypertarget{WUT_8h_a23a6}{
WUT\_\-K\_\-CANCELLED}
\label{WUT_8h_a23a6}
}]It's been cancelled \index{WUT_K_EXPIRED@{WUT\_\-K\_\-EXPIRED}!WUT.h@{WUT.h}}\index{WUT.h@{WUT.h}!WUT_K_EXPIRED@{WUT\_\-K\_\-EXPIRED}}\item[{\em 
\hypertarget{WUT_8h_a23a7}{
WUT\_\-K\_\-EXPIRED}
\label{WUT_8h_a23a7}
}]It's been serviced \end{description}
\end{Desc}



\subsection{Function Documentation}
\hypertarget{WUT_8h_a13}{
\index{WUT.h@{WUT.h}!WUT_cancel@{WUT\_\-cancel}}
\index{WUT_cancel@{WUT\_\-cancel}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-cancel]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{WUT_8h_a1}{WUT\_\-state} WUT\_\-cancel (\hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$ {\em wut})}}
\label{WUT_8h_a13}


Cancels a WUT timer entry. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wut}]The WUT timer entry to cancel \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The new state. If successful this is WUT\_\-K\_\-CANCELLED\end{Desc}
\begin{Desc}
\item[]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.\end{Desc}
\hypertarget{WUT_8h_a14}{
\index{WUT.h@{WUT.h}!WUT_create@{WUT\_\-create}}
\index{WUT_create@{WUT\_\-create}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-create]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$ WUT\_\-create (void)}}
\label{WUT_8h_a14}


Allocate a WUT timer entry. 

\begin{Desc}
\item[Returns:]If successful, a handle for WUT timer entry, else NULL\end{Desc}
\begin{Desc}
\item[]Allocates, without blocking a WUT timer entry. If successful, the state of the timer entry is updated to WUT\_\-K\_\-ALLOCATED.\end{Desc}
\hypertarget{WUT_8h_a21}{
\index{WUT.h@{WUT.h}!WUT_dec_get@{WUT\_\-dec\_\-get}}
\index{WUT_dec_get@{WUT\_\-dec\_\-get}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-dec\_\-get]{\setlength{\rightskip}{0pt plus 5cm}int WUT\_\-dec\_\-get (void)}}
\label{WUT_8h_a21}


Gets the current time left till the next timer expiration. 

This primarily used as a debugging aid.\hypertarget{WUT_8h_a16}{
\index{WUT.h@{WUT.h}!WUT_destroy@{WUT\_\-destroy}}
\index{WUT_destroy@{WUT\_\-destroy}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-destroy]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{WUT_8h_a1}{WUT\_\-state} WUT\_\-destroy (\hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$ {\em wut})}}
\label{WUT_8h_a16}


Destroys, ie frees, an unused WUT timer entry. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wut}]The WUT timer entry to destroy \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]If successful, WUT\_\-K\_\-FREE, else its current state.\end{Desc}
\begin{Desc}
\item[]A WUT timer entry can only be destroyed, ie returned to the free list, if it is in the state\end{Desc}
\begin{itemize}
\item WUT\_\-K\_\-ALLOCATED\item WUT\_\-K\_\-CANCELLED\item WUT\_\-K\_\-EXPIRED\item or if it being destroyed as part of its ISR callback routine.\end{itemize}


\begin{Desc}
\item[]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.\end{Desc}
\hypertarget{WUT_8h_a15}{
\index{WUT.h@{WUT.h}!WUT_expire@{WUT\_\-expire}}
\index{WUT_expire@{WUT\_\-expire}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-expire]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{WUT_8h_a1}{WUT\_\-state} WUT\_\-expire (\hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$ {\em wut})}}
\label{WUT_8h_a15}


Marks a wut timer as expire. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wut}]The WUT timer entry to expire \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]IF successful, WUT\_\-K\_\-EXPIRED, else the current state\end{Desc}
\begin{Desc}
\item[]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.\end{Desc}
\begin{Desc}
\item[Warning:]This mechanism should be used instead of passing back {\em WUT\_\-K\_\-STATE\_\-CHANGED\_\-YES\/} or {\em 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 Vx\-Works and not {\bf any} of the host platforms. So to be {\em portable\/} and {\em correct\/}, use this call in lieu of the return code. The return code in portable code should now always be {\em 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.\end{Desc}
\begin{Desc}
\item[]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.\end{Desc}
\begin{Desc}
\item[]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.\end{Desc}
\hypertarget{WUT_8h_a22}{
\index{WUT.h@{WUT.h}!WUT_frequency@{WUT\_\-frequency}}
\index{WUT_frequency@{WUT\_\-frequency}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-frequency]{\setlength{\rightskip}{0pt plus 5cm}unsigned int WUT\_\-frequency (void)}}
\label{WUT_8h_a22}


Gets frequency, in Hertz of the WUT clock. 

\begin{Desc}
\item[Returns:]The frequency in Hertz of the WUT clock\end{Desc}
\begin{Desc}
\item[]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.\end{Desc}
\hypertarget{WUT_8h_a17}{
\index{WUT.h@{WUT.h}!WUT_restart@{WUT\_\-restart}}
\index{WUT_restart@{WUT\_\-restart}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-restart]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{WUT_8h_a1}{WUT\_\-state} WUT\_\-restart (\hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$ {\em wut}, register \hyperlink{TOV_8h_8px-xxx-xxx_a8}{TOV} {\em tov})}}
\label{WUT_8h_a17}


Restarts a WUT timer entry. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wut}]The WUT timer entry to restart. \item[{\em tov}]The timeout value. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]If successful, WUT\_\-K\_\-QUEUED\end{Desc}
\begin{Desc}
\item[]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 {\em 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 \hyperlink{WUT_8h_a17}{WUT\_\-restart()} returns the state of the timer entry.\end{Desc}
\hypertarget{WUT_8h_a18}{
\index{WUT.h@{WUT.h}!WUT_start@{WUT\_\-start}}
\index{WUT_start@{WUT\_\-start}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-start]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{WUT_8h_a1}{WUT\_\-state} WUT\_\-start (\hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$ {\em wut}, register \hyperlink{TOV_8h_8px-xxx-xxx_a8}{TOV} {\em tov}, \hyperlink{WUT__cb_8h_a1}{WUT\_\-cb\_\-routine} {\em cb}, void $\ast$ {\em prm})}}
\label{WUT_8h_a18}


Establishes and starts a WUT timer entry. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wut}]The WUT timer entry to restart. \item[{\em tov}]The timeout value \item[{\em cb}]The address of the WUT timer entry's callback service routine. \item[{\em prm}]A user parameter passed transparently through to the timer entry's callback service routine \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]If successful, WUT\_\-K\_\-QUEUED\end{Desc}
\begin{Desc}
\item[]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.\end{Desc}
\begin{Desc}
\item[]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 \hyperlink{WUT_8h_a17}{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.\end{Desc}
\begin{Desc}
\item[]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.\end{Desc}
\hypertarget{WUT_8h_a19}{
\index{WUT.h@{WUT.h}!WUT_state_get@{WUT\_\-state\_\-get}}
\index{WUT_state_get@{WUT\_\-state\_\-get}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-state\_\-get]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{WUT_8h_a1}{WUT\_\-state} WUT\_\-state\_\-get (const \hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$ {\em wut})}}
\label{WUT_8h_a19}


Gets the current state of the WUT timer entry. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wut}]The WUT timer entry to get the state for. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The current state of the WUT timer entry.\end{Desc}
\begin{Desc}
\item[]Simple query routine to return the current state of a timer entry.\end{Desc}
\begin{Desc}
\item[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.\end{Desc}
\hypertarget{WUT_8h_a8}{
\index{WUT.h@{WUT.h}!WUT_sys_adjust@{WUT\_\-sys\_\-adjust}}
\index{WUT_sys_adjust@{WUT\_\-sys\_\-adjust}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-sys\_\-adjust]{\setlength{\rightskip}{0pt plus 5cm}int WUT\_\-sys\_\-adjust (long long int {\em dnsecx})}}
\label{WUT_8h_a8}


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

\begin{Desc}
\item[Returns:]The number of entries that were adjusted\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dnsecx}]The number of nanoseconds to shift the timer que entries by.\end{description}
\end{Desc}
\begin{Desc}
\item[]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.\end{Desc}
\begin{Desc}
\item[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.\end{Desc}
\hypertarget{WUT_8h_a10}{
\index{WUT.h@{WUT.h}!WUT_sys_connect@{WUT\_\-sys\_\-connect}}
\index{WUT_sys_connect@{WUT\_\-sys\_\-connect}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-sys\_\-connect]{\setlength{\rightskip}{0pt plus 5cm}int WUT\_\-sys\_\-connect (unsigned int {\em keepalive}, unsigned int {\em update})}}
\label{WUT_8h_a10}


One time WUT connection routine to start WUT system. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em keepalive}]The timeout period, in nsecs, to run the keepalive timer. \item[{\em 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. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Status\end{Desc}
\hypertarget{WUT_8h_a9}{
\index{WUT.h@{WUT.h}!WUT_sys_init@{WUT\_\-sys\_\-init}}
\index{WUT_sys_init@{WUT\_\-sys\_\-init}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-sys\_\-init]{\setlength{\rightskip}{0pt plus 5cm}int WUT\_\-sys\_\-init (int {\em count})}}
\label{WUT_8h_a9}


One time WUT services initialization routine. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em count}]The number of available timer entries \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Status\end{Desc}
\begin{Desc}
\item[]Initializes a pool of Wake\-Up 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 ($\sim$50 bytes) so one should allocate generously.\end{Desc}
\begin{Desc}
\item[]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.\end{Desc}
\hypertarget{WUT_8h_a11}{
\index{WUT.h@{WUT.h}!WUT_sys_reset@{WUT\_\-sys\_\-reset}}
\index{WUT_sys_reset@{WUT\_\-sys\_\-reset}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-sys\_\-reset]{\setlength{\rightskip}{0pt plus 5cm}int WUT\_\-sys\_\-reset (unsigned int {\em keepalive}, unsigned int {\em update})}}
\label{WUT_8h_a11}


Resets the keepalive and update times. 

\begin{Desc}
\item[Returns:]Status\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em keepalive}]The timeout period, in nsecs, to run the keepalive timer. One values is recognized as special\begin{enumerate}
\item 0, Leave as is\item anything else, The new keepalive period\end{enumerate}
\item[{\em update}]The new update period (in nanoseconds). Three values are recognized\begin{enumerate}
\item -1, Remove the updater, the implication is that the caller is assuming responsibility for this function\item 0, Leave as is\item anything else, the new update time, in nanoseconds\end{enumerate}
\end{description}
\end{Desc}
\begin{Desc}
\item[]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.\end{Desc}
\hypertarget{WUT_8h_a12}{
\index{WUT.h@{WUT.h}!WUT_sys_shutdown@{WUT\_\-sys\_\-shutdown}}
\index{WUT_sys_shutdown@{WUT\_\-sys\_\-shutdown}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-sys\_\-shutdown]{\setlength{\rightskip}{0pt plus 5cm}int WUT\_\-sys\_\-shutdown (void)}}
\label{WUT_8h_a12}


Shuts down the WUT routine. 

\begin{Desc}
\item[Returns:]Status, 1 indicates WUT was not started, so cannot be shutdown. \end{Desc}
\begin{Desc}
\item[]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.\end{Desc}
\begin{Desc}
\item[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$>$\end{Desc}
\begin{Desc}
\item[]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.\end{Desc}
\hypertarget{WUT_8h_a20}{
\index{WUT.h@{WUT.h}!WUT_tov_get@{WUT\_\-tov\_\-get}}
\index{WUT_tov_get@{WUT\_\-tov\_\-get}!WUT.h@{WUT.h}}
\subsubsection[WUT\_\-tov\_\-get]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{WUT_8h_a1}{WUT\_\-state} WUT\_\-tov\_\-get (const \hyperlink{struct__WUT__tmr}{WUT\_\-tmr} $\ast$ {\em wut})}}
\label{WUT_8h_a20}


Gets the current TOV of the WUT timer entry. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wut}]The WUT timer entry to get the TOV for. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The current TOV of the WUT timer entry.\end{Desc}
\begin{Desc}
\item[]Simply query routine to return the current state of a timer entry.\end{Desc}
\begin{Desc}
\item[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.\end{Desc}
