vxColor.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:6k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* vxColor.h -  header file for vxColor2.c program */
  2. /* Copyright 1984-1998 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01f,09apr98,dbt increased stack size for solaris simulator.
  7. 01e,15nov95,jcf renamed vxColor2.h to vxColor.h.  sigh.
  8. 01d,15nov95,jcf renamed vxColor.h to vxColor2.h.
  9. 01c,27sep95,jco re coding convention revision, removed rev field in GNODE.
  10. 01b,06sep95,p_m fixed coding convention problems.
  11. 01a,03aug95,jco written.
  12. */
  13. /* WARNING: DEMO_EOLM MUST BE SUPERIOR TO MAX_NODE! If DEMO_EOLM is changed 
  14.  * here, it MUST also be changed in $WIND_BASE/host/src/demo/color/demoHost.tk.
  15.  */
  16. /* defines */
  17. #define MAX_NODE 100 /* maximum node number in a graph */
  18. #define MAX_CONNEX 10 /* maximum node connectivity number */
  19. #define MAX_MSG 1 /* maximum number of message in queue */
  20. #define MSG_SIZE sizeof (NODE_ATTRIB) /* message size */
  21. #define MAX_COLOR 6 /* maximum number of color */
  22. #define MAX_OUTDEGREE 5 /* maximum node outdegree */
  23. #define OUTDEGREE_INIT (MAX_OUTDEGREE + 1)
  24. #define PAUSE_CLK_RATIO 10  /* clckRate divisor (N sec for Pause) */
  25. #define DEMO_EOLM 127 /* connexions file endOfLine marker */
  26. #define CONT_PRIORITY 200 /* controler's task priority */
  27. #define NODE_PRIORITY 200 /* node's tasks priority */
  28. #define NODE_STBL_INIT  -1 /* initial value for stable field */
  29. #define NODE_UNSTABLE 0 /* unstable value for stable field */
  30. #define NODE_STABLE 1 /* stable value for stable field */
  31. /*
  32.  * stackSize defines according to cpu type and debug mode boolean 
  33.  */
  34. #if (defined (CPU_FAMILY) && (CPU_FAMILY==MC680X0))
  35. #define NODE_STACK 500 /* node task stack size */
  36. #define NODE_STACK_DBG 1000 /* node task stack size for debug */
  37. #define CONT_STACK 500 /* graphControl task stack size */
  38. #define CONT_STACK_DBG 1000 /* graphControl stack size for debug */
  39. #endif  /* CPU_FAMILY == MC680X0 */
  40. #if (defined (CPU_FAMILY) && (CPU_FAMILY==SIMSPARCSUNOS))
  41. #define NODE_STACK 2500 /* node task stack size */
  42. #define NODE_STACK_DBG 5000 /* node task stack size for debug */
  43. #define CONT_STACK 2500 /* graphControl task stack size */
  44. #define CONT_STACK_DBG 5000 /* graphControl stack size for debug */
  45. #endif  /* CPU_FAMILY == SPARC */
  46. #if (defined (CPU_FAMILY) && (CPU_FAMILY==I80X86))
  47. #define NODE_STACK 500 /* node task stack size */
  48. #define NODE_STACK_DBG 1000 /* node task stack size for debug */
  49. #define CONT_STACK 500 /* graphControl task stack size */
  50. #define CONT_STACK_DBG 1000 /* graphControl stack size for debug */
  51. #endif  /* CPU_FAMILY == I80X86 */
  52. #if (defined (CPU_FAMILY) && (CPU_FAMILY==I960))
  53. #define NODE_STACK 1000 /* node task stack size */
  54. #define NODE_STACK_DBG 2000 /* node task stack size for debug */
  55. #define CONT_STACK 1000 /* graphControl task stack size */
  56. #define CONT_STACK_DBG 2000 /* graphControl stack size for debug */
  57. #endif  /* CPU_FAMILY == I960 */
  58. #if (defined (CPU_FAMILY) && (CPU_FAMILY==SIMSPARCSOLARIS))
  59. #define NODE_STACK 5000 /* node task stack size */
  60. #define NODE_STACK_DBG 10000 /* node task stack size for debug */
  61. #define CONT_STACK 5000 /* graphControl task stack size */
  62. #define CONT_STACK_DBG 10000 /* graphControl stack size for debug */
  63. #endif  /* CPU_FAMILY == SIMSPARCSOLARIS */
  64. /* default values */
  65. #ifndef NODE_STACK
  66. #define NODE_STACK 2500 /* node task stack size */
  67. #define NODE_STACK_DBG 5000 /* node task stack size for debug */
  68. #define CONT_STACK 2500 /* graphControl task stack size */
  69. #define CONT_STACK_DBG 5000 /* graphControl stack size for debug */
  70. #endif /* not def NODE_STACK */
  71. #if (defined (CPU_FAMILY) && (CPU_FAMILY==I960) && (defined __GNUC__))
  72. #pragma align 1                 /* tell gcc960 not to optimize alignments */
  73. #endif  /* CPU_FAMILY==I960 */
  74. /* typedefs */
  75. typedef struct ids /* IDS */
  76.     {
  77.     INT32 tid; /* task id */
  78.     INT32 nid; /* node id */
  79.     } IDS; /* task/node id */
  80. typedef struct node_attrib /* NODE_ATTRIB */
  81.     {
  82.     INT32 color; /* node color */
  83.     INT32 Xvalue; /* node Xvalue */
  84.     } NODE_ATTRIB; /* node attributes */
  85. typedef struct connect_info /* CONNECT_INFO */
  86.     {
  87.     INT32 dir; /* direction: +=to connected -=from connected */
  88.     IDS tnid; /* connected node tid & nid */
  89.     NODE_ATTRIB att; /* connected node attributes */
  90.     MSG_Q_ID wMQId; /* write (toNeighbor) mesg queue id */
  91.     MSG_Q_ID rMQId; /* read  (toNeighbor) mesg queue id */
  92.     } CONNECT_INFO; /* connected node info */
  93. typedef struct gnode_st /* GNODE */ 
  94.     {
  95.     INT32 stable; /* color stability flag */
  96.     IDS tnid; /* node tid & nid */
  97.     NODE_ATTRIB att; /* node col & Xval */
  98.     INT32 pc; /* node Prog Counter */
  99.     INT32 oD; /* node outDegree */
  100.     INT32 cNum; /* node connexions # */
  101.     CONNECT_INFO cArray [MAX_CONNEX]; /* node connexions array */
  102.     struct gnode_st * pNext; /* pointer to pNext gnode */
  103.     } GNODE; /* global node info */
  104. typedef struct control /* CONTROL */
  105.     {
  106.     char        steadyState;            /* flag on if graph is stable */
  107.     char        controlAlive;           /* flag on if control task is alive */
  108.     char coloringStop;           /* flag on when stop requested */
  109.     char        pauseOn;                /* flag on when pause requested */
  110.     INT32       graphControlId;         /* graphControl task Id */
  111.     INT32       nodeFailure;            /* flag on if a node task in error */
  112.     SEM_ID nodeJobDoneSem; /* synchro for controler */
  113.     SEM_ID      createAckSem;           /* Ack for each node creation */
  114.     SEM_ID restartSem; /* StartColoring and control synchro */
  115.     SEM_ID connexionsDoneSem; /* connexions established synchro */
  116.     SEM_ID controlerFlushSem; /* controler flush semaphore */
  117.     SEM_ID      dataBaseMutex;          /* data base mutex semaphore */
  118.     } CONTROL; /* global control info */
  119. typedef struct data_base /* DATA_BASE */
  120.     {
  121.     CONTROL cT; /* control info block */
  122.     INT32 nNum; /* graph node # */
  123.     GNODE * pFirstGnode; /* pointer to first gnode */
  124.     } DATA_BASE; /* global graph info */
  125. /* turn off alignment requirement for i960 cpu family */
  126. #if (defined (CPU_FAMILY) && (CPU_FAMILY==I960) && (defined __GNUC__))
  127. #pragma align 0
  128. #endif  /* CPU_FAMILY==I960 */
  129. /* forward declarations defining the demo GUI API */
  130. INT32 graphColorUpdate (DATA_BASE * pdB, char * colorMemBlkAdd);
  131. INT32 graphInit (INT32 nodNumber, char * colorMemBlkAdd, BOOL debugMode);
  132. INT32 graphStartColoring (DATA_BASE * pdB);
  133. INT32  graphStop (DATA_BASE * pdB);