GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> PBS / dev > test_rng / rhel6-64


Interface   Data Structures   File List   Data Fields   Globals  

TASK.h File Reference

Task/Thread facility, a portable interface between VxWorks and POSIX implementations, callable version. More...

#include <PBS/TOV.h>

Classes

struct  _TASK_attr
 Encapsulates the more esoteric options. More...

Defines

#define TASK_PRINTF(_args)
 Debugging macro acting as a stand in for printf.
#define TASK_K_NAME_MAX   16
 The maximum size of a task's name, including the terminating NUL character.

Typedefs

typedef struct _TASK_attr TASK_attr
 Typedef for struct _TASK_attr.
typedef enum _TASK_priority_type TASK_priority_type
 Typedef for enum _TASK_priority_type.
typedef void * TASK_parameter
 The type of the parameter passed to the task's entry point routine.
typedef void *(* TASK_entry )(TASK_parameter parameter)
 The function signature of the task's entry point routine.
typedef struct _TASK_tcb TASK_tcb
 TASK facility's definition of a Task Control Block.
typedef int TASK_int
typedef int(* TASK_block_cb )(void *prm)
 Callback routine of TASK_block.

Enumerations

enum  _TASK_priority_type {
  TASK_K_PRIORITY_TYPE_ABS = 0,
  TASK_K_PRIORITY_TYPE_REL = 1
}
 Indicates how a priority specification to TASK_attr_setpriority is interpretted. More...

Functions

int TASK_attr_init (TASK_attr *attributes)
int TASK_attr_priority_set (TASK_attr *attributes, int priority)
int TASK_activate (TASK_tcb *tcb)
int TASK_create (TASK_tcb *tcb, const TASK_attr *attributes, TASK_entry entry_point, TASK_parameter parameter)
TASK_int TASK_convert (TASK_tcb *tcb, const TASK_attr *attributes, TASK_entry entry_point, TASK_parameter parameter)
int TASK_spawn (TASK_tcb *tcb, const TASK_attr *attributes, TASK_entry entry_point, TASK_parameter parameter)
int TASK_destroy (TASK_tcb *tcb)
void TASK_exit (void *status)
int TASK_join (TASK_tcb *tcb, void **status)
int TASK_revert (TASK_tcb *tcb)
TASK_tcbTASK_cvt (void)
int TASK_rvt (void)
int TASK_pause (unsigned int nsecs)
int TASK_resume (TASK_tcb *tcb)
int TASK_suspend (TASK_tcb *tcb)
int TASK_wait (const TOV tov)
int TASK_block (TASK_block_handle *tbh, TASK_block_cb rtn, void *prm)
int TASK_unblock (TASK_block_handle tbh)
int TASK_priority_get (const TASK_tcb *tcb)
int TASK_tcb_sizeof (void)
int TASK_xtcb_sizeof (void)
TASK_tcbTASK_self (void)
const char * TASK_name (const TASK_tcb *tcb)
int TASK_priority_number_boost (int priority, int boost)
int TASK_priority_number_compute (int priority, TASK_priority_type type, const TASK_tcb *tcb)
int TASK_priority_number_limit (int priority)
int TASK_priority_set (TASK_tcb *tcb, int priority)


Detailed Description

Task/Thread facility, a portable interface between VxWorks and POSIX implementations, callable version.

Author:
JJRussell - russell@slac.stanford.edu

   CVS $Id: TASK.h,v 1.7 2011/03/24 23:05:44 apw Exp $

SYNOPSIS
These routines attempt to make TASK/THREAD manipulation portable across VxWorks and POSIX implementations. The thread models of these two systems are rather different so this is not an easy job and the rough edges certainly show.
PRIORITIES
The VxWorks and POSIX priorities are, unfortunately very different. The VxWorks priorities run from the highest (0) to the lowest (255). POSIX priorities run from the lowest (1) to the highest (99).
One possibly portable scheme would map the two priorities into a common set. For example, accept the POSIX priorities and map the VxWorks priorities into them or vica-versa. Unfortunately either way has problems. This mapping could be done in one of two ways. The first would map the full range of the VxWorks set to the full range of the POSIX set. This mapping scheme could cause two different VxWorks priorities to map to the same POSIX priority, changing the priority relationship between the two tasks. This is unacceptable.

Another way would be to map some restricted range of the VxWorks set (say 0-98) to the POSIX range. This is better but suffers from another problem. Some VxWorks layered products start tasks that run at very specific priorities, for example, the Network task when running with a TCP/IP stack. The user must be careful to correctly position his task's priority relative to these tasks. Restricting the range VxWork's range could impair this ability.

Another possibility is to map the POSIX set to the VxWorks set. One would always specify priorities in the POSIX scheme. This would avoid the problem of mapping two different priorities to the identical priorities. The cost of this would be to restrict the VxWorks priority set to 100 different priorities. This might be acceptable, but runs counter to the PBS philosophy of providing a portable set of routines biased towards the VxWorks implementation.

In the end, there is really no good way to merge these two different schemes. The compromise is that absolute priorities are deemed to be not a portable concept. If the user chooses to use absolute priorities, it is up to him to layer this out. The TASK routines will, however, support the concept of RAISING and LOWERING priorities by a fixed delta. The only restriction is that the resulting priority must lie within the implementations acceptable range. Note that RAISING and LOWERING always means a task with a higher priority runs before a task of lower priority. In the VxWorks implementation RAISING the priority results in lowering the task's priority number. (God, this is confusing.)

Two sets of limits are given

                Symbol                       Meaning  VxWorks POSIX
   TASK_K_PRIORITY_MIN  Minimum task priority number        0     1
   TASK_K_PRIORITY_MAX  Maximum task priority number      255    99

   TASK_K_PRIORITY_LO   Lowest  task priority number      255     1
   TASK_K_PRIORITY_HI   Highest task priority number        0    99

  

The first set is useful for limit checking, i.e. making sure a given priority is acceptable on that platform. The second set allows one to implement a relative mapping scheme.

STACKS
The POSIX version supports only specifying a stack size. In both the VxWorks and POSIX cases TASK_K_STACK_SIZE_MIN provides a symbol for the minimum stack size. The VxWorks version supports stack allocation. It is up to the user to figure out how to make this portable. Sorry....

Define Documentation

#define TASK_K_NAME_MAX   16

The maximum size of a task's name, including the terminating NUL character.

This quantity is defined for portability reasons. One some platforms, there is no maximum size, but, given that the only value of the name is for display purposes, it makes it easier to write displays if the name is limited to some reasonable number of characters. So, the request is that the user's of TASK limit the task names to this value independent of whether the underlying OS supports more or not. Note, however, that the TASK facility does not enforce this policy.

#define TASK_PRINTF ( _args   ) 

Debugging macro acting as a stand in for printf.

Parameters:
_args A parenthesis inclosed set of arguments to printf
This macro is active iff the compiler symbol TASK_DEBUG is defined, otherwise it is defined as a NOP


Typedef Documentation

Typedef for struct _TASK_attr.

This data structure allows the caller to fine tune the task creation parameters in a semi-portable fashion. Not all fields are supported on all platforms.

int(* TASK_block_cb)(void *prm)

Callback routine of TASK_block.

Returns:
status
Parameters:
A user parameter passed to the callback routine

The function signature of the task's entry point routine.

This is the function signature of the task's entry point routine. It is as simple as one can make it, i.e.

        void *exit_parameter = (*entry_point) (TASK_parameter parameter);
  

The TASK_parameter is just a void *, but is typedef'd so that the code documents neatly.

The type of the parameter passed to the task's entry point routine.

This type is just a void *, but is typedef'd so that the code documents neatly.

Typedef for enum _TASK_priority_type.

Indicates how a priority specification to TASK_attr_setpriority is interpretted. This can be either as an absolute or as a signed number relative to the another task's priority.

TASK facility's definition of a Task Control Block.

The user should never manipulate this data structure directly. It is provided only so the compiler can lay down storage. Direct manipulation will kill the portability of the code since the exact contents are platform dependent.


Enumeration Type Documentation

Indicates how a priority specification to TASK_attr_setpriority is interpretted.

Enumerator:
TASK_K_PRIORITY_TYPE_ABS  Interpret priority as an absolute
TASK_K_PRIORITY_TYPE_REL  Interpret priority relative to the current task's priority


Generated on Fri Aug 5 17:10:13 2011 by  doxygen 1.5.8