\hypertarget{FORK_8c}{
\section{FORK.c File Reference}
\label{FORK_8c}\index{FORK.c@{FORK.c}}
}
The FORK routines.  


{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include $<$PBI/Ofs.h$>$}\par
{\tt \#include $<$IPBS/PL.ih$>$}\par
{\tt \#include $<$IPBS/LI.ih$>$}\par
{\tt \#include $<$IPBS/TASK.h$>$}\par
{\tt \#include $<$IPBS/TOC.h$>$}\par
{\tt \#include $<$TASK\_\-pvtdefs.h$>$}\par
{\tt \#include $<$IPBS/FORK.h$>$}\par
\subsection*{Classes}
\begin{CompactItemize}
\item 
union \hyperlink{union__FORK__que}{\_\-FORK\_\-que}
\begin{CompactList}\small\item\em Structure defining a FORK\_\-que. \item\end{CompactList}\item 
union \hyperlink{union__FORK__que__head}{\_\-FORK\_\-que\_\-head}
\begin{CompactList}\small\item\em Structure defining a FORK\_\-que\_\-head. The FORK routines are set up to manage to types of ques, a simply linked list or a Priority List of ques. This is simply a union of the controlling list heads. \item\end{CompactList}\item 
struct \hyperlink{struct__FORK__fcb}{\_\-FORK\_\-fcb}
\begin{CompactList}\small\item\em Defines Fork Control Block containing the global information about the FORK que. \item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{FORK_8c_5c2192b637e822f9f824ffd5f96f168b}{
typedef union \hyperlink{union__FORK__que__head}{\_\-FORK\_\-que\_\-head} \hyperlink{FORK_8c_5c2192b637e822f9f824ffd5f96f168b}{FORK\_\-que\_\-head}}
\label{FORK_8c_5c2192b637e822f9f824ffd5f96f168b}

\begin{CompactList}\small\item\em Typedef for a FORK\_\-que\_\-head. \item\end{CompactList}\item 
\hypertarget{FORK_8c_1f900594a0eaa816a481faac1a3e40ad}{
typedef enum \hyperlink{FORK_8c_58c795f051815d21e8f68b8b6dbb887c}{\_\-FORK\_\-msg\_\-type} \hyperlink{FORK_8c_1f900594a0eaa816a481faac1a3e40ad}{FORK\_\-msg\_\-type}}
\label{FORK_8c_1f900594a0eaa816a481faac1a3e40ad}

\begin{CompactList}\small\item\em Typedef for enum FORK\_\-msg\_\-type. \item\end{CompactList}\end{CompactItemize}
\subsection*{Enumerations}
\begin{CompactItemize}
\item 
enum \hyperlink{FORK_8c_58c795f051815d21e8f68b8b6dbb887c}{\_\-FORK\_\-msg\_\-type} \{ \par
\hyperlink{FORK_8c_58c795f051815d21e8f68b8b6dbb887c6538952095fd818e4cc9aa4df95beca6}{FORK\_\-K\_\-MSG\_\-TYPE\_\-USR} =  0, 
\par
\hyperlink{FORK_8c_58c795f051815d21e8f68b8b6dbb887c64bcf6c8ac1f8764aec953eb8df30315}{FORK\_\-K\_\-MSG\_\-TYPE\_\-SYS} =  1
 \}
\begin{CompactList}\small\item\em Distinguishes between the two types of messages, user or system. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
int \hyperlink{FORK_8c_949af1519a2209aa73ec7d982e0e82f5}{FORK\_\-fcb\_\-sizeof} (int nques)
\begin{CompactList}\small\item\em Returns the size, in bytes, of a FORK Control Block. \item\end{CompactList}\item 
int \hyperlink{FORK_8c_3b4c011d49916f5ecd5985b59920725f}{FORK\_\-create} (\hyperlink{struct__FORK__fcb}{FORK\_\-fcb} $\ast$fcb, const struct \hyperlink{struct__TASK__attr}{\_\-TASK\_\-attr} $\ast$attributes, \hyperlink{FORK_8h_d363d06744c7977f7e4e3a24b2894ee6}{FORK\_\-cb\_\-rtn} def\_\-handler, \hyperlink{FORK_8h_f660e49ed86875626289202bfbdf775b}{FORK\_\-cb\_\-prm} ctx, \hyperlink{FORK_8h_f660e49ed86875626289202bfbdf775b}{FORK\_\-cb\_\-prm} tmo\_\-ctx, const \hyperlink{struct__TOC}{TOC} $\ast$tmo\_\-toc, int nques, const \hyperlink{struct__FORK__que__cfg}{FORK\_\-que\_\-cfg} $\ast$que\_\-cfg, \hyperlink{FORK_8h_f9cfab5a9ce7764816c2931a0c6196d8}{FORK\_\-type} msg\_\-type, \hyperlink{struct__FORK__msg__sys}{FORK\_\-msg\_\-sys} $\ast$msg\_\-blks, int msg\_\-cnt)
\begin{CompactList}\small\item\em Creates a FORK message que. \item\end{CompactList}\item 
\hyperlink{union__FORK__que}{FORK\_\-que} $\ast$ \hyperlink{FORK_8c_a05d4a4718b04e1c937f662466eb410b}{FORK\_\-que\_\-get} (\hyperlink{struct__FORK__fcb}{FORK\_\-fcb} $\ast$fcb, int que\_\-id)
\begin{CompactList}\small\item\em Returns a handle to the specified que. \item\end{CompactList}\item 
int \hyperlink{FORK_8c_6099241d84faa779026dcfbcafad72dc}{FORK\_\-destroy} (\hyperlink{struct__FORK__fcb}{FORK\_\-fcb} $\ast$fcb)
\begin{CompactList}\small\item\em Destroys a FORK que. \item\end{CompactList}\item 
\hyperlink{FORK_8h_24f907af9d061b5371778055e66a0253}{FORK\_\-que\_\-list} \hyperlink{FORK_8c_f55066fd2116e16dbbab2a984c0aff2c}{FORK\_\-disable} (\hyperlink{struct__FORK__fcb}{FORK\_\-fcb} $\ast$fcb, \hyperlink{FORK_8h_24f907af9d061b5371778055e66a0253}{FORK\_\-que\_\-list} disable\_\-list)
\begin{CompactList}\small\item\em Disables the servicing of the specified ques. \item\end{CompactList}\item 
\hyperlink{FORK_8h_24f907af9d061b5371778055e66a0253}{FORK\_\-que\_\-list} \hyperlink{FORK_8c_7abdbec08c120375132c9aeeac99fb73}{FORK\_\-enable} (\hyperlink{struct__FORK__fcb}{FORK\_\-fcb} $\ast$fcb, \hyperlink{FORK_8h_24f907af9d061b5371778055e66a0253}{FORK\_\-que\_\-list} enable\_\-list)
\begin{CompactList}\small\item\em Enables the servicing of the specified ques. \item\end{CompactList}\item 
\hyperlink{FORK_8h_24f907af9d061b5371778055e66a0253}{FORK\_\-que\_\-list} \hyperlink{FORK_8c_c1d8d3884ddaf1e1b5f8ed36a5acbcb3}{FORK\_\-enabled} (const \hyperlink{struct__FORK__fcb}{FORK\_\-fcb} $\ast$fcb)
\begin{CompactList}\small\item\em Returns the enable/disabled state of the specified que. \item\end{CompactList}\item 
int \hyperlink{FORK_8c_a78dd66e4725ef84db99bfc683fd6c3a}{FORK\_\-qdisable} (\hyperlink{union__FORK__que}{FORK\_\-que} $\ast$que)
\begin{CompactList}\small\item\em Disables the servicing of the specified que. \item\end{CompactList}\item 
int \hyperlink{FORK_8c_9d443f02418ce9e8d785df78ce206a3f}{FORK\_\-qenable} (\hyperlink{union__FORK__que}{FORK\_\-que} $\ast$que)
\begin{CompactList}\small\item\em Enables the servicing of the specified que. \item\end{CompactList}\item 
int \hyperlink{FORK_8c_10b80f0749d7fdbe63d96f0ecbb792e2}{FORK\_\-qenabled} (const \hyperlink{union__FORK__que}{FORK\_\-que} $\ast$que)
\begin{CompactList}\small\item\em Returns the enable/disabled state of all ques. \item\end{CompactList}\item 
int \hyperlink{FORK_8c_fa24c8a1e2caeca4380b31784880aaca}{FORK\_\-qhead\_\-modify} (\hyperlink{union__FORK__que}{FORK\_\-que} $\ast$que, \hyperlink{FORK_8h_f3621df59fce088b614da85fafadf136}{FORK\_\-cb\_\-modify} modify, void $\ast$context)
\begin{CompactList}\small\item\em Sneaky way to modify the head (oldest) element on the specified FORK que. \item\end{CompactList}\item 
int \hyperlink{FORK_8c_1972d6e939c221bd90da6957b09082db}{FORK\_\-qtail\_\-modify} (\hyperlink{union__FORK__que}{FORK\_\-que} $\ast$que, \hyperlink{FORK_8h_f3621df59fce088b614da85fafadf136}{FORK\_\-cb\_\-modify} modify, void $\ast$context)
\begin{CompactList}\small\item\em Sneaky way to modify the tail (newest) element on the specified FORK que. \item\end{CompactList}\item 
int \hyperlink{FORK_8c_0334b8cb7840c9ad53aafe6577c09734}{FORK\_\-qsys} (\hyperlink{union__FORK__que}{FORK\_\-que} $\ast$que, \hyperlink{FORK_8h_d363d06744c7977f7e4e3a24b2894ee6}{FORK\_\-cb\_\-rtn} handler, void $\ast$contents)
\begin{CompactList}\small\item\em Ques a message using the internal FORK message blocks. \item\end{CompactList}\item 
int \hyperlink{FORK_8c_acfd0201adb38f6f19179d7bcc0a3cd4}{FORK\_\-qsysW} (\hyperlink{union__FORK__que}{FORK\_\-que} $\ast$que, \hyperlink{FORK_8h_d363d06744c7977f7e4e3a24b2894ee6}{FORK\_\-cb\_\-rtn} handler, void $\ast$contents)
\begin{CompactList}\small\item\em Ques a message using the internal FORK message blocks. \item\end{CompactList}\item 
int \hyperlink{FORK_8c_4302135e4e4eddd89c007ba96d055f12}{FORK\_\-qsysW\_\-toc} (\hyperlink{union__FORK__que}{FORK\_\-que} $\ast$que, \hyperlink{FORK_8h_d363d06744c7977f7e4e3a24b2894ee6}{FORK\_\-cb\_\-rtn} handler, void $\ast$contents, const \hyperlink{struct__TOC}{TOC} $\ast$tmo\_\-toc)
\begin{CompactList}\small\item\em Ques a message using the internal FORK message blocks. \item\end{CompactList}\item 
int \hyperlink{FORK_8c_dddfdc45e7df37c1a6b732a0666dbb6d}{FORK\_\-qusr} (\hyperlink{union__FORK__que}{FORK\_\-que} $\ast$que, \hyperlink{FORK_8h_d363d06744c7977f7e4e3a24b2894ee6}{FORK\_\-cb\_\-rtn} handler, \hyperlink{struct__FORK__msg__hdr}{FORK\_\-msg\_\-hdr} $\ast$msg\_\-hdr)
\begin{CompactList}\small\item\em Ques a user composed message. \item\end{CompactList}\item 
int \hyperlink{FORK_8c_5ee04d00d9507f5a51656cdab2b11af1}{FORK\_\-resume} (\hyperlink{struct__FORK__fcb}{FORK\_\-fcb} $\ast$fcb)
\begin{CompactList}\small\item\em Resumes a previously suspended FORK task. \item\end{CompactList}\item 
int \hyperlink{FORK_8c_4f58824796443838e8cdbcd9f270fef5}{FORK\_\-suspend} (\hyperlink{struct__FORK__fcb}{FORK\_\-fcb} $\ast$fcb)
\begin{CompactList}\small\item\em Suspends the FORK task. \item\end{CompactList}\item 
int \hyperlink{FORK_8c_ccb257c3da656954b6b99f72b185f8f6}{FORK\_\-join} (\hyperlink{struct__FORK__fcb}{FORK\_\-fcb} $\ast$fcb, int $\ast$exit\_\-status)
\begin{CompactList}\small\item\em Waits until the FORK'd task is deleted. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
The FORK routines. 

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


\footnotesize\begin{verbatim}
   CVS $Id: FORK.c,v 1.2 2011/03/25 21:14:41 saxton Exp $
   
\end{verbatim}
\normalsize


\begin{Desc}
\item[SYNOPIS]The FORK routines provide a clean mechanism for implementing what looks like a function call across threads/tasks. An interlocked message que is created between the task that calls \hyperlink{FORK_8c_3b4c011d49916f5ecd5985b59920725f}{FORK\_\-create()} and the task created by the \hyperlink{FORK_8c_3b4c011d49916f5ecd5985b59920725f}{FORK\_\-create()}. Messages can be placed on this que by any task that has access to the que through the Fork Control Block. In this sense, it is a multi-writer, single-reader half-duplex communication link.\end{Desc}
These routines serve much the same purpose as the VxWorks msgQ routines with some important advantages

1. The FORK routines allow user controller over memory allocation.

The msgQ routines allocate memory when a request to send a message is made. If no memory is available, the user may either have the call return with failure or block. Ignoring the 'return with failure option' a problem occurs when blocking is not an option, as in an interrupt service routine. The FORK routines allow the user to pre-allocate the message buffer before committing to servicing an interrupt. This ensures that the necessary resources are in hand.

2. The burden of creating the receiving task is taken on by the \hyperlink{FORK_8c_3b4c011d49916f5ecd5985b59920725f}{FORK\_\-create()} routine.

Since the metaphor of the FORK routines is to transparently {\bf fork} the execution path, this seems more natural than manually creating an task/thread to handle the messages. In most cases, this is all the create task is going to do, ie pend on a message que and service the incominig messages.

3. The messsage to be queued is not copied twice as it is in the VxWorks routines (once when sending and once when receiving).

This is a direct consequence of allowing the user to do his own management of the message buffers. Many times memory allocation can be avoid altogether. All the FORK routines demand is two free 32 bit locations (one for a link management and the other for a dispatch routine). Both locations are used only when on the FORK que. Many times the user can find two free location in the piece of information being sent, thus avoiding allocation (and, more importantly, handling the case of failure to allocate) altogether.

4. The FORK routines offer the option of managing a number (up to 32) priority order ques.

This feature allows higher priority messages to be serviced first, effectively creating an out-of-band mechanism.

A good use for these would be a command receiver/command handler. Assuming the receiver and handler are in different threads, the receiver receives incoming commands, decides which FORK que they should be assigned to and the function that such be executed. The received packages this information along with the command parameters and ques it. The handler thread wakes out and executes the command.

\begin{Desc}
\item[USAGE]The user first creates the FORK que by calling \hyperlink{FORK_8c_3b4c011d49916f5ecd5985b59920725f}{FORK\_\-create()}. \hyperlink{FORK_8c_3b4c011d49916f5ecd5985b59920725f}{FORK\_\-create()} allows control over all the parameters of the FORK que, including the attributes of the FORK servicing task. The user also has the option having the FORK routines create an internally managed pool of message buffers. Choosing this option makes the FORK routines behave very similarly to the msqQ routines with a buffer size of 4 bytes.\end{Desc}
A queued message always consists of two quantities, a routine to handle the message and the message contents itself. If the internal message pool, referred to here as the system pool, is used, the contents of the message are limited to a single 32 bit number. If the user chooses to que his own messages, the contents can be any size he wishes, his only obligation is to preface the message with a FORK\_\-msg\_\-hdr structure. Messages of varying sizes and types, ie both user and system messages, can be queued to the same FORK que. The deallocation of user messages is the responsibility of the user, while system messages are freed immediately after the dispatch routine finishes its processing.

This latter design choice has only a slight impact on performance, since, in theory, the dispatch routine could release the message memory earlier. However, given the single reader nature of the FORK utilities, only one such buffer can be outstanding at an given time. The truly concerned user can avoid this limitation by using only message buffers that he manages.

\begin{Desc}
\item[EXAMPLE]

\begin{Code}\begin{verbatim}    int test_fork (void)
    {
    FORK_fcb   *fcb;
    FORK_que   *que;
    int        size;
    int exit_status;

    / * Allocate 10 message blocks for the FORK ques internal pool * /
    FORK_msg_sys msg_blks[10];
    int          msg_blk_cnt = sizeof (msg_blks) / sizeof (*msg_blks);

    size = FORK_fcb_sizeof (1);             / * Size of Fork Control Block  * /
    fcb  = (FORK_fcb *) MBA_alloc (size);   / * Allocate the memory for it  * /

    / * Create the fork que                                                 * /
    status = FORK_create (fcb,              / * Fork Control Block to init  * /
                          NULL,             / * Use default task attributes * /
                          normalPrint,      / * Default handling routine    * /
                          forkParameter,    / * Parameter passed to handler * /
                          forkTmoParameter, / * Parameter passed if timeout * /
                          TOC_FOREVER,      / * How long to pend before tmo * /
                          1,                / * One internal FORK que       * /
                          NULL,             / * Individual que cfg's        * /
                          FORK_K_TYPE_PENDING_WTO,,
                                            / * FIFO style blocking when    * /
                                            / * allocating system messges   * /
                          msg_blks,         / * A source of message blocks  * /
                          msg_blk_cnt)      / * Number of messge blocks     * /

                          
    / *
     |  Retrieve the que to post messages to. In this example the FORK
     |  routines were initialized to support only a single que, so the
     |  que to be located in que = 0
 /
    que    = FORK_get_que (fcb, 0);

    / * Post a series of messages to this que * /
    status = FORK_qsysW   (que, NULL,      "Hello World\n");
    status = FORK_qsysW   (que, boldPrint, "Goodbye World\n");
    status = FORK_qsysW   (que, winddown,  "Killing FORK'd task\n");
    status = FORK_join    (que, &exit_status);

    / *
     |   All done, kill the que. Note that this call blocks until the
     |   the FORK'd task has completed its work.
 / 
    status = FORK_destroy (fcb);
    free (fcb);

    return 0;
    }
    
    
    int normalPrint (void *parameter, FORK_msg_sys *msg)
    {
       fputs (msg->contents);
       return FORK_C_CONTINUE;
    }

    int boldPrint (void *parameter, FORK_msg_sys *msg)
    {
      printf ("%s", BOLD_ESC_SEQUENCE);
      fputs (msg->contents);
      printf ("%s", NORMAL_ESC_SEQUENCE);
      return FORK_C_CONTINUE;
    }

    int winddown (void *parameter, FORK_msg_sys *msg)
    {
      fputs (msg->contents);
      fflush (stdout);

      / * Indicate that this is it * /
      return 1;
    }
\end{verbatim}
\end{Code}

\end{Desc}
\begin{Desc}
\item[]The usual precautions should be heeded. For example, in this example, not allowing the creating task to terminate when messages are still on the que. Since the memory is from stack, that would be bad. \end{Desc}


\subsection{Enumeration Type Documentation}
\hypertarget{FORK_8c_58c795f051815d21e8f68b8b6dbb887c}{
\index{FORK.c@{FORK.c}!\_\-FORK\_\-msg\_\-type@{\_\-FORK\_\-msg\_\-type}}
\index{\_\-FORK\_\-msg\_\-type@{\_\-FORK\_\-msg\_\-type}!FORK.c@{FORK.c}}
\subsubsection[{\_\-FORK\_\-msg\_\-type}]{\setlength{\rightskip}{0pt plus 5cm}enum {\bf \_\-FORK\_\-msg\_\-type}}}
\label{FORK_8c_58c795f051815d21e8f68b8b6dbb887c}


Distinguishes between the two types of messages, user or system. 

\begin{Desc}
\item[Enumerator: ]\par
\begin{description}
\index{FORK\_\-K\_\-MSG\_\-TYPE\_\-USR@{FORK\_\-K\_\-MSG\_\-TYPE\_\-USR}!FORK.c@{FORK.c}}\index{FORK.c@{FORK.c}!FORK\_\-K\_\-MSG\_\-TYPE\_\-USR@{FORK\_\-K\_\-MSG\_\-TYPE\_\-USR}}\item[{\em 
\hypertarget{FORK_8c_58c795f051815d21e8f68b8b6dbb887c6538952095fd818e4cc9aa4df95beca6}{
FORK\_\-K\_\-MSG\_\-TYPE\_\-USR}
\label{FORK_8c_58c795f051815d21e8f68b8b6dbb887c6538952095fd818e4cc9aa4df95beca6}
}]The message type is a user provided \index{FORK\_\-K\_\-MSG\_\-TYPE\_\-SYS@{FORK\_\-K\_\-MSG\_\-TYPE\_\-SYS}!FORK.c@{FORK.c}}\index{FORK.c@{FORK.c}!FORK\_\-K\_\-MSG\_\-TYPE\_\-SYS@{FORK\_\-K\_\-MSG\_\-TYPE\_\-SYS}}\item[{\em 
\hypertarget{FORK_8c_58c795f051815d21e8f68b8b6dbb887c64bcf6c8ac1f8764aec953eb8df30315}{
FORK\_\-K\_\-MSG\_\-TYPE\_\-SYS}
\label{FORK_8c_58c795f051815d21e8f68b8b6dbb887c64bcf6c8ac1f8764aec953eb8df30315}
}]The message type is a system provided \end{description}
\end{Desc}



\subsection{Function Documentation}
\hypertarget{FORK_8c_3b4c011d49916f5ecd5985b59920725f}{
\index{FORK.c@{FORK.c}!FORK\_\-create@{FORK\_\-create}}
\index{FORK\_\-create@{FORK\_\-create}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-create}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-create ({\bf FORK\_\-fcb} $\ast$ {\em fcb}, \/  const struct {\bf \_\-TASK\_\-attr} $\ast$ {\em attributes}, \/  {\bf FORK\_\-cb\_\-rtn} {\em def\_\-handler}, \/  {\bf FORK\_\-cb\_\-prm} {\em ctx}, \/  {\bf FORK\_\-cb\_\-prm} {\em tmo\_\-ctx}, \/  const {\bf TOC} $\ast$ {\em tmo\_\-toc}, \/  int {\em nques}, \/  const {\bf FORK\_\-que\_\-cfg} $\ast$ {\em que\_\-cfg}, \/  {\bf FORK\_\-type} {\em msg\_\-type}, \/  {\bf FORK\_\-msg\_\-sys} $\ast$ {\em msg\_\-blks}, \/  int {\em msg\_\-cnt})}}
\label{FORK_8c_3b4c011d49916f5ecd5985b59920725f}


Creates a FORK message que. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em fcb}]The FORK Control Block to initialize \item[{\em attributes}]The attributes to use when creating the FORK servicing task. \item[{\em def\_\-handler}]The address of a default FORK handler. This routine will be called back in one of two circumstances.\end{description}
\end{Desc}
\begin{enumerate}
\item The user does not provide an explicit routine queing the message.\item A timeout occurs\par
\end{enumerate}


\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ctx}]Parameter passed transparently to the user's callback handler, except in the case of a timeout. \item[{\em tmo\_\-ctx}]Parameter passed transparently to the user's callback routine in case of a timeout. The user may use this parameter to distinguish a timeout condition from a normal message. (The message block will also be NULL in this case.) \item[{\em tmo\_\-toc}]Timeout control specification. This is used when a message is being pended for. If this value is TOC\_\-FOREVER, the pend is indefinite. \end{description}
\end{Desc}
\begin{Desc}
\item[Warning:]Do not pass NULL for this parameter. The standard intepretation of NULL for a timeout control block is as NO\_\-WAIT. This is almost certainly not what one wants in the FORK routines. \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em nques}]If specified as 0 or 1, a single non-prioritized que is used. If specified as $>$1, multiple prioritized ques are used. {\em que\_\-cfg\/} configures each of the ques. \item[{\em que\_\-cfg}]An array of que configuration blocks. If {\em nques\/} is specified as 0 or 1, this parameter is ignored. If the callback routine is specified as NULL for any individual que configuration, the default callback handler is used. \item[{\em msg\_\-type}]The blocking type to use when attempting allocate a message from the system queue. There are three blocking styles. \par
\end{description}
\end{Desc}
\begin{enumerate}
\item Non-blocking, this is the equivalent of a poll and is not very useful\item Blocking without a timeout. This is the equivalent of a indefinite wait for a message.\item Blocking with a timeout. \begin{Desc}
\item[Note:]This parameter is applicable if and only if one is using a system pool to allocate messages from. Use of a system pool is determined by a non-zero message count, {\em msg\_\-cnt\/} \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em msg\_\-blks}]A source of internal message blocks. This may be specified as NULL and is ignored if {\em msg\_\-cnt\/} is specified as 0. \end{description}
\end{Desc}
\begin{Desc}
\item[Note:]This parameter is applicable if and only if one is using a system pool to allocate messages from. Use of a system pool is determined by a non-zero message count, {\em msg\_\-cnt\/} \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em msg\_\-cnt}]The number of {\em msg\_\-blks\/}. This may be specified as 0. In this case no system message pool is created and the values of the parameters {\em msg\_\-type\/} and msg\_\-blks are ignored.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Status\end{Desc}
This routine creates the FORK message que and its associated task. The {\em def\_\-handler\/} will be used as the callback handler when a message is queued without an explicit handler, see \hyperlink{FORK_8c_acfd0201adb38f6f19179d7bcc0a3cd4}{FORK\_\-qsysW()}, FORK\_\-qsysWTO(), and FORK\_\-quser(). It is also used when a timeout occurs. \end{enumerate}


References \_\-FORK\_\-fcb::cfg, \_\-FORK\_\-que\_\-cfg::ctx, \_\-FORK\_\-fcb::def, \_\-FORK\_\-fcb::enabled, \_\-FORK\_\-fcb::freelist, \_\-FORK\_\-que\_\-cfg::handler, \_\-FORK\_\-que\_\-head::li, LI\_\-init(), LI\_\-K\_\-TYPE\_\-PENDING\_\-WTO, \_\-FORK\_\-fcb::msg\_\-beg, \_\-FORK\_\-fcb::msg\_\-cnt, \_\-FORK\_\-fcb::msg\_\-end, \_\-FORK\_\-fcb::nques, \_\-FORK\_\-fcb::pend, \_\-FORK\_\-que\_\-head::pl, PL\_\-init(), PL\_\-K\_\-TYPE\_\-PENDING\_\-WTO, PL\_\-SIZEOF, \_\-FORK\_\-fcb::rw, RW\_\-init(), RW\_\-K\_\-TYPE\_\-PENDING, TASK\_\-spawn(), TASK\_\-tcb\_\-sizeof(), \_\-FORK\_\-fcb::tcb, \_\-FORK\_\-que\_\-cfg::tmo\_\-ctx, \_\-FORK\_\-fcb::tmo\_\-toc, \_\-FORK\_\-fcb::toc\_\-buf, TOC\_\-IS\_\-FOREVER, and TOC\_\-IS\_\-NOWAIT.\hypertarget{FORK_8c_6099241d84faa779026dcfbcafad72dc}{
\index{FORK.c@{FORK.c}!FORK\_\-destroy@{FORK\_\-destroy}}
\index{FORK\_\-destroy@{FORK\_\-destroy}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-destroy}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-destroy ({\bf FORK\_\-fcb} $\ast$ {\em fcb})}}
\label{FORK_8c_6099241d84faa779026dcfbcafad72dc}


Destroys a FORK que. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em fcb}]The Fork Control Block of the FORK que to destroy \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Status\end{Desc}
Releases all the internal resources used by the FORK que. It does not release either the memory associated with any potential internal pool of message blocks that the FORK routines may be managing on behalf of the user, nor does it release the memory associated with the Fork Control Block itself. Both these are user providef blocks of memory and, therefore, user managed blocks of memories.

The usual method of winding down the FORK task is for the parent task to send a QUIT message to the FORK'd task. The parent task then calls FORK\_\-join, which block until the FORK'd task exits. The FORK'd task performs any necessary clean-up then returns a non-zero status code from the callback routine. This causes the FORK'd task to delete itself, allowing the \hyperlink{FORK_8c_ccb257c3da656954b6b99f72b185f8f6}{FORK\_\-join()} call to complete.

\begin{Desc}
\item[Warning:]As with all delete operations, care must be taken to ensure it is safe to destroy the FORK que. The above suggests one method of doing this. \end{Desc}


References \_\-FORK\_\-fcb::freelist, \_\-FORK\_\-que\_\-head::li, LI\_\-destroy(), \_\-FORK\_\-fcb::msg\_\-cnt, \_\-FORK\_\-fcb::nques, \_\-FORK\_\-fcb::pend, \_\-FORK\_\-que\_\-head::pl, PL\_\-destroy(), \_\-FORK\_\-fcb::rw, and RW\_\-destroy().\hypertarget{FORK_8c_f55066fd2116e16dbbab2a984c0aff2c}{
\index{FORK.c@{FORK.c}!FORK\_\-disable@{FORK\_\-disable}}
\index{FORK\_\-disable@{FORK\_\-disable}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-disable}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-disable ({\bf FORK\_\-fcb} $\ast$ {\em fcb}, \/  {\bf FORK\_\-que\_\-list} {\em disable\_\-list})}}
\label{FORK_8c_f55066fd2116e16dbbab2a984c0aff2c}


Disables the servicing of the specified ques. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em fcb}]The FORK Control Block \item[{\em disable\_\-list}]The list of ques to disable \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The list of previously of enabled ques \end{Desc}


References \_\-FORK\_\-fcb::enabled, \_\-FORK\_\-que\_\-head::li, LI\_\-\_\-disable(), \_\-PL\_\-ctl::mcfg, \_\-FORK\_\-fcb::nques, \_\-FORK\_\-fcb::pend, \_\-FORK\_\-que\_\-head::pl, \_\-FORK\_\-fcb::rw, RW\_\-\_\-lock(), and RW\_\-\_\-unlock().

Referenced by FORK\_\-qdisable().\hypertarget{FORK_8c_7abdbec08c120375132c9aeeac99fb73}{
\index{FORK.c@{FORK.c}!FORK\_\-enable@{FORK\_\-enable}}
\index{FORK\_\-enable@{FORK\_\-enable}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-enable}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-enable ({\bf FORK\_\-fcb} $\ast$ {\em fcb}, \/  {\bf FORK\_\-que\_\-list} {\em enable\_\-list})}}
\label{FORK_8c_7abdbec08c120375132c9aeeac99fb73}


Enables the servicing of the specified ques. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em fcb}]The FORK Control Block \item[{\em enable\_\-list}]The list of ques to enable \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The list of previously of enabled ques \end{Desc}


References \_\-FORK\_\-fcb::enabled, \_\-FORK\_\-que\_\-head::li, LI\_\-\_\-enable(), \_\-PL\_\-ctl::mcfg, \_\-FORK\_\-fcb::nques, \_\-FORK\_\-fcb::pend, \_\-FORK\_\-que\_\-head::pl, PL\_\-\_\-wake(), \_\-FORK\_\-fcb::rw, RW\_\-\_\-lock(), and RW\_\-\_\-unlock().

Referenced by FORK\_\-qenable().\hypertarget{FORK_8c_c1d8d3884ddaf1e1b5f8ed36a5acbcb3}{
\index{FORK.c@{FORK.c}!FORK\_\-enabled@{FORK\_\-enabled}}
\index{FORK\_\-enabled@{FORK\_\-enabled}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-enabled}]{\setlength{\rightskip}{0pt plus 5cm}{\bf FORK\_\-que\_\-list} FORK\_\-enabled (const {\bf FORK\_\-fcb} $\ast$ {\em fcb})}}
\label{FORK_8c_c1d8d3884ddaf1e1b5f8ed36a5acbcb3}


Returns the enable/disabled state of the specified que. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em fcb}]The FORK control block \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A list of the enabled ques, MSB = que 0.\end{Desc}
\begin{Desc}
\item[Warning:]As with all queries of this type, the answer is only good until it changes. The user is cautioned on its usage. It is primarily provided as a debugging tool. \end{Desc}


References \_\-FORK\_\-fcb::enabled, \_\-FORK\_\-que\_\-head::li, LI\_\-\_\-enabled(), \_\-FORK\_\-fcb::nques, and \_\-FORK\_\-fcb::pend.\hypertarget{FORK_8c_949af1519a2209aa73ec7d982e0e82f5}{
\index{FORK.c@{FORK.c}!FORK\_\-fcb\_\-sizeof@{FORK\_\-fcb\_\-sizeof}}
\index{FORK\_\-fcb\_\-sizeof@{FORK\_\-fcb\_\-sizeof}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-fcb\_\-sizeof}]{\setlength{\rightskip}{0pt plus 5cm}FORK\_\-fcb\_\-sizeof (int {\em nques})}}
\label{FORK_8c_949af1519a2209aa73ec7d982e0e82f5}


Returns the size, in bytes, of a FORK Control Block. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em nques}]The number of internal ques to be supported \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The sizeof of a fork control block\end{Desc}
Returns the size of a FORK CONTROL BLOCK. This allows the user to allocate and control the FORK CONTROL BLOCK without making its internal structure known.

The FORK routines are capable of supporting multiple prioritized internal ques. This is done by specifying {\em nques\/} to be greater than 1. 

References PL\_\-SIZEOF, and TASK\_\-tcb\_\-sizeof().\hypertarget{FORK_8c_ccb257c3da656954b6b99f72b185f8f6}{
\index{FORK.c@{FORK.c}!FORK\_\-join@{FORK\_\-join}}
\index{FORK\_\-join@{FORK\_\-join}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-join}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-join ({\bf FORK\_\-fcb} $\ast$ {\em fcb}, \/  int $\ast$ {\em exit\_\-status})}}
\label{FORK_8c_ccb257c3da656954b6b99f72b185f8f6}


Waits until the FORK'd task is deleted. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em fcb}]The Fork Control Block \item[{\em exit\_\-status}]Returned as the exit status of the FORK'd task. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Status of the join operation.\end{Desc}
This allows the parent task to synchronize with the deletion of the FORK'd task.

The usual method of winding down the FORK task is for the parent task to send a QUIT message to the FORK'd task. The parent task then calls FORK\_\-join, which block until the FORK'd task exits. The FORK'd task performs any necessary clean-up then returns a non-zero status code from the callback routine. (This status code is returned to the user as {\em exit\_\-status\/}.) This causes the FORK'd task to delete itself, allowing the \hyperlink{FORK_8c_ccb257c3da656954b6b99f72b185f8f6}{FORK\_\-join()} call to complete. The user is then free to call \hyperlink{FORK_8c_6099241d84faa779026dcfbcafad72dc}{FORK\_\-destroy()} to return the resources garnered by the FORK fcb.

Note that the {\em exit\_\-status\/} may be returned as any non-zero 32-bit value. This includes returning a pointer to a structure which may contain additional information. If one does this, one must be careful to ensure that the memory is viable after task deletion. For instance, don't return pointers to things on the stack. 

References TASK\_\-join(), and \_\-FORK\_\-fcb::tcb.\hypertarget{FORK_8c_a78dd66e4725ef84db99bfc683fd6c3a}{
\index{FORK.c@{FORK.c}!FORK\_\-qdisable@{FORK\_\-qdisable}}
\index{FORK\_\-qdisable@{FORK\_\-qdisable}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-qdisable}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-qdisable ({\bf FORK\_\-que} $\ast$ {\em que})}}
\label{FORK_8c_a78dd66e4725ef84db99bfc683fd6c3a}


Disables the servicing of the specified que. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0,if}]the specified que was not originally enabled !=0, if the specified que was previously enabled\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em que}]The FORK que to disable\end{description}
\end{Desc}
\begin{Desc}
\item[Warning:]Note that the return value is the original state of the {\bf all} enables before the qdisable was performed. \end{Desc}


References FORK\_\-disable(), \_\-PL\_\-que::id, \_\-FORK\_\-que::pl, and PL\_\-LIST.\hypertarget{FORK_8c_9d443f02418ce9e8d785df78ce206a3f}{
\index{FORK.c@{FORK.c}!FORK\_\-qenable@{FORK\_\-qenable}}
\index{FORK\_\-qenable@{FORK\_\-qenable}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-qenable}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-qenable ({\bf FORK\_\-que} $\ast$ {\em que})}}
\label{FORK_8c_9d443f02418ce9e8d785df78ce206a3f}


Enables the servicing of the specified que. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0,if}]the specified que was not originally enabled !=0, if the specified que was previously enabled\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em que}]The FORK que to enable \end{description}
\end{Desc}


References FORK\_\-enable(), \_\-PL\_\-que::id, \_\-FORK\_\-que::pl, and PL\_\-LIST.\hypertarget{FORK_8c_10b80f0749d7fdbe63d96f0ecbb792e2}{
\index{FORK.c@{FORK.c}!FORK\_\-qenabled@{FORK\_\-qenabled}}
\index{FORK\_\-qenabled@{FORK\_\-qenabled}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-qenabled}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-qenabled (const {\bf FORK\_\-que} $\ast$ {\em que})}}
\label{FORK_8c_10b80f0749d7fdbe63d96f0ecbb792e2}


Returns the enable/disabled state of all ques. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em =}]0 if the queue was previously disabled != 0 if the queue was previously enabled \end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em que}]The que to query\end{description}
\end{Desc}
\begin{Desc}
\item[Warning:]As with all queries of this type, the answer is only good until it changes. The user is cautioned on its usage. It is primarily provided as a debugging tool. \end{Desc}


References \_\-FORK\_\-fcb::enabled, \_\-PL\_\-que::id, \_\-FORK\_\-que\_\-head::li, LI\_\-\_\-enabled(), \_\-FORK\_\-fcb::nques, \_\-FORK\_\-fcb::pend, \_\-FORK\_\-que::pl, and PL\_\-LIST.\hypertarget{FORK_8c_fa24c8a1e2caeca4380b31784880aaca}{
\index{FORK.c@{FORK.c}!FORK\_\-qhead\_\-modify@{FORK\_\-qhead\_\-modify}}
\index{FORK\_\-qhead\_\-modify@{FORK\_\-qhead\_\-modify}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-qhead\_\-modify}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-qhead\_\-modify ({\bf FORK\_\-que} $\ast$ {\em que}, \/  {\bf FORK\_\-cb\_\-modify} {\em modify}, \/  void $\ast$ {\em context})}}
\label{FORK_8c_fa24c8a1e2caeca4380b31784880aaca}


Sneaky way to modify the head (oldest) element on the specified FORK que. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em que}]The target fork que. \item[{\em modify}]A callback handler used to modify the que element. The return value of this callback routine is the return value of FORK\_\-qhead\_\-modify. \end{description}
\end{Desc}
\begin{Desc}
\item[Warning:]If the que is empty, NULL is passed as the msg\_\-hdr header in the callback routine. \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em context}]A user provided context parameter. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Whatever the user callback routine does. \end{Desc}
\hypertarget{FORK_8c_0334b8cb7840c9ad53aafe6577c09734}{
\index{FORK.c@{FORK.c}!FORK\_\-qsys@{FORK\_\-qsys}}
\index{FORK\_\-qsys@{FORK\_\-qsys}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-qsys}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-qsys ({\bf FORK\_\-que} $\ast$ {\em que}, \/  {\bf FORK\_\-cb\_\-rtn} {\em handler}, \/  void $\ast$ {\em contents})}}
\label{FORK_8c_0334b8cb7840c9ad53aafe6577c09734}


Ques a message using the internal FORK message blocks. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em que}]The target fork que. \item[{\em handler}]A callback handler. This may be specified as NULL, in which case, the default handler established by \hyperlink{FORK_8c_3b4c011d49916f5ecd5985b59920725f}{FORK\_\-create()}, will handle the message. \item[{\em contents}]A single 32-bit value representing the message contents. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Status\end{Desc}
Ques a message to the FORK message que using the internal system message pool. System messages are limited to queing a single 32-bit number. Of course one can always use this to que a pointer to another data structure. The user should consider \hyperlink{FORK_8c_dddfdc45e7df37c1a6b732a0666dbb6d}{FORK\_\-qusr()}, to que a more complicated message without absorbing another level of indirection.

Note that because the message is internally allocated it may be possible that this list is exhausted. This version of the routine returns immediately with failure if the list is exhausted. See {\em \hyperlink{FORK_8c_acfd0201adb38f6f19179d7bcc0a3cd4}{FORK\_\-qsysW()}\/} or {\em FORK\_\-qsysW\_\-toc\/} for wait forever and wait with a timeout versions 

References \_\-FORK\_\-msg\_\-sys::contents, FORK\_\-K\_\-MSG\_\-TYPE\_\-SYS, \_\-FORK\_\-fcb::freelist, \_\-FORK\_\-msg\_\-sys::hdr, and LI\_\-\_\-remove().\hypertarget{FORK_8c_acfd0201adb38f6f19179d7bcc0a3cd4}{
\index{FORK.c@{FORK.c}!FORK\_\-qsysW@{FORK\_\-qsysW}}
\index{FORK\_\-qsysW@{FORK\_\-qsysW}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-qsysW}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-qsysW ({\bf FORK\_\-que} $\ast$ {\em que}, \/  {\bf FORK\_\-cb\_\-rtn} {\em handler}, \/  void $\ast$ {\em contents})}}
\label{FORK_8c_acfd0201adb38f6f19179d7bcc0a3cd4}


Ques a message using the internal FORK message blocks. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em que}]The target fork que. \item[{\em handler}]A callback handler. This may be specified as NULL, in which case, the default handler established by \hyperlink{FORK_8c_3b4c011d49916f5ecd5985b59920725f}{FORK\_\-create()}, will handle the message. \item[{\em contents}]A single 32-bit value representing the message contents. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Status\end{Desc}
Ques a message to the FORK message que using the internal system message pool. System messages are limited to queing a single 32-bit number. Of course one can always use this to que a pointer to another data structure. The user should consider \hyperlink{FORK_8c_dddfdc45e7df37c1a6b732a0666dbb6d}{FORK\_\-qusr()}, to que a more complicated message without absorbing another level of indirection.

Note that because the message is internally allocated it may be possible that this list is exhausted. This version of the routine waits indefinitely until a message becomes available. See {\em \hyperlink{FORK_8c_0334b8cb7840c9ad53aafe6577c09734}{FORK\_\-qsys()}\/} or {\em FORK\_\-qsysW\_\-toc\/} for no wait and wait with timeout versions. 

References \_\-FORK\_\-msg\_\-sys::contents, FORK\_\-K\_\-MSG\_\-TYPE\_\-SYS, \_\-FORK\_\-fcb::freelist, \_\-FORK\_\-msg\_\-sys::hdr, and LI\_\-\_\-removeW().\hypertarget{FORK_8c_4302135e4e4eddd89c007ba96d055f12}{
\index{FORK.c@{FORK.c}!FORK\_\-qsysW\_\-toc@{FORK\_\-qsysW\_\-toc}}
\index{FORK\_\-qsysW\_\-toc@{FORK\_\-qsysW\_\-toc}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-qsysW\_\-toc}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-qsysW\_\-toc ({\bf FORK\_\-que} $\ast$ {\em que}, \/  {\bf FORK\_\-cb\_\-rtn} {\em handler}, \/  void $\ast$ {\em contents}, \/  const {\bf TOC} $\ast$ {\em tmo\_\-toc})}}
\label{FORK_8c_4302135e4e4eddd89c007ba96d055f12}


Ques a message using the internal FORK message blocks. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em que}]The target fork que. \item[{\em handler}]A callback handler. This may be specified as NULL, in which case, the default handler established by \hyperlink{FORK_8c_3b4c011d49916f5ecd5985b59920725f}{FORK\_\-create()}, will handle the message. \item[{\em contents}]A single 32-bit value representing the message contents. \item[{\em tmo\_\-toc}]A timeout control structure. This is used when no system message blocks available. The values TOC\_\-NOWAIT and TOC\_\-FOREVER can be used here. The information in this structure is copied, so the user may free the memory after the call. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Status\end{Desc}
Ques a message to the FORK message que using the internal system message pool. System messages are limited to queing a single 32-bit number. Of course one can always use this to que a pointer to another data structure. The user should consider \hyperlink{FORK_8c_dddfdc45e7df37c1a6b732a0666dbb6d}{FORK\_\-qusr()}, to que a more complicated message without absorbing another level of indirection.

Note that because the message is internally allocated it may be possible that this list is exhausted. A timeout parameter is provided to handle this situation. See {\em \hyperlink{FORK_8c_0334b8cb7840c9ad53aafe6577c09734}{FORK\_\-qsys()}\/} or {\em FORK\_\-qsysW\/} for no wait and wait forever versions. 

References \_\-FORK\_\-msg\_\-sys::contents, FORK\_\-K\_\-MSG\_\-TYPE\_\-SYS, \_\-FORK\_\-fcb::freelist, \_\-FORK\_\-msg\_\-sys::hdr, and LI\_\-\_\-removeW\_\-toc().\hypertarget{FORK_8c_1972d6e939c221bd90da6957b09082db}{
\index{FORK.c@{FORK.c}!FORK\_\-qtail\_\-modify@{FORK\_\-qtail\_\-modify}}
\index{FORK\_\-qtail\_\-modify@{FORK\_\-qtail\_\-modify}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-qtail\_\-modify}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-qtail\_\-modify ({\bf FORK\_\-que} $\ast$ {\em que}, \/  {\bf FORK\_\-cb\_\-modify} {\em modify}, \/  void $\ast$ {\em context})}}
\label{FORK_8c_1972d6e939c221bd90da6957b09082db}


Sneaky way to modify the tail (newest) element on the specified FORK que. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em que}]The target fork que. \item[{\em modify}]A callback handler used to modify the que element. The return value of this callback routine is the return value of FORK\_\-qhead\_\-modify. \end{description}
\end{Desc}
\begin{Desc}
\item[Warning:]If the que is empty, NULL is passed as the msg\_\-hdr header in the callback routine. \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em context}]A user provided context parameter. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Whatever the user callback routine does. \end{Desc}
\hypertarget{FORK_8c_a05d4a4718b04e1c937f662466eb410b}{
\index{FORK.c@{FORK.c}!FORK\_\-que\_\-get@{FORK\_\-que\_\-get}}
\index{FORK\_\-que\_\-get@{FORK\_\-que\_\-get}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-que\_\-get}]{\setlength{\rightskip}{0pt plus 5cm}{\bf FORK\_\-que} $\ast$ FORK\_\-que\_\-get ({\bf FORK\_\-fcb} $\ast$ {\em fcb}, \/  int {\em que\_\-id})}}
\label{FORK_8c_a05d4a4718b04e1c937f662466eb410b}


Returns a handle to the specified que. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em fcb}]The FORK Control Block \item[{\em que\_\-id}]The ID of the que \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A handle to the specified que or NULL if no such que exists.\end{Desc}
The FORK que routines take a FORK que as a parameter. This is used routine is used to get that handle. When a single que is managed by the FORK routines, only a {\em que\_\-id\/} of 0 is allowed. When multiple ques are managed by the FORK routines, then an a {\em que\_\-id\/} up to nques - 1 is allowed, with que\_\-id = 0 being the highest priority que. 

References \_\-FORK\_\-que\_\-head::li, \_\-FORK\_\-fcb::nques, \_\-FORK\_\-fcb::pend, \_\-FORK\_\-que\_\-head::pl, and PL\_\-\_\-que\_\-get().\hypertarget{FORK_8c_dddfdc45e7df37c1a6b732a0666dbb6d}{
\index{FORK.c@{FORK.c}!FORK\_\-qusr@{FORK\_\-qusr}}
\index{FORK\_\-qusr@{FORK\_\-qusr}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-qusr}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-qusr ({\bf FORK\_\-que} $\ast$ {\em que}, \/  {\bf FORK\_\-cb\_\-rtn} {\em handler}, \/  {\bf FORK\_\-msg\_\-hdr} $\ast$ {\em msg\_\-hdr})}}
\label{FORK_8c_dddfdc45e7df37c1a6b732a0666dbb6d}


Ques a user composed message. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em que}]The target fork que. \item[{\em handler}]A callback handler. This may be specified as NULL, in which case, the default handler established by \hyperlink{FORK_8c_3b4c011d49916f5ecd5985b59920725f}{FORK\_\-create()}, will handle the message. \item[{\em msg\_\-hdr}]Pointer to the message to que. It is mandatory that all queued messages are prefaced by a standard message header block \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Status\end{Desc}
Ques a user defined message. This routine behaves in much the same manner as \hyperlink{FORK_8c_0334b8cb7840c9ad53aafe6577c09734}{FORK\_\-qsys()}, except the message being queued is controlled almost entirely by the user. (The except part, is that the message must be prefaced by a standard message header.)

For the extra work involved in using this routine, the user gets to control his own memory allocation and the exact contents of the message. This means that there is almost no case, other than an internal corruption, under which this routine can fail. 

References FORK\_\-K\_\-MSG\_\-TYPE\_\-USR.\hypertarget{FORK_8c_5ee04d00d9507f5a51656cdab2b11af1}{
\index{FORK.c@{FORK.c}!FORK\_\-resume@{FORK\_\-resume}}
\index{FORK\_\-resume@{FORK\_\-resume}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-resume}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-resume ({\bf FORK\_\-fcb} $\ast$ {\em fcb})}}
\label{FORK_8c_5ee04d00d9507f5a51656cdab2b11af1}


Resumes a previously suspended FORK task. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em fcb}]The FORK Control Block \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Status\end{Desc}
\begin{Desc}
\item[Warning:]This routine and its companion, {\em \hyperlink{FORK_8c_4f58824796443838e8cdbcd9f270fef5}{FORK\_\-suspend()}\/}, are primarily intended to be used for debugging and test code purposes. \end{Desc}


References TASK\_\-resume(), and \_\-FORK\_\-fcb::tcb.\hypertarget{FORK_8c_4f58824796443838e8cdbcd9f270fef5}{
\index{FORK.c@{FORK.c}!FORK\_\-suspend@{FORK\_\-suspend}}
\index{FORK\_\-suspend@{FORK\_\-suspend}!FORK.c@{FORK.c}}
\subsubsection[{FORK\_\-suspend}]{\setlength{\rightskip}{0pt plus 5cm}int FORK\_\-suspend ({\bf FORK\_\-fcb} $\ast$ {\em fcb})}}
\label{FORK_8c_4f58824796443838e8cdbcd9f270fef5}


Suspends the FORK task. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em fcb}]The FORK Control Block \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Status\end{Desc}
\begin{Desc}
\item[Warning:]This routine and its companion, {\em \hyperlink{FORK_8c_5ee04d00d9507f5a51656cdab2b11af1}{FORK\_\-resume()}\/}, are primarily intended to be used for debugging and test code purposes. \end{Desc}


References TASK\_\-suspend(), and \_\-FORK\_\-fcb::tcb.