Netcruzer Library API  V2.03
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
nzos_task.h
Go to the documentation of this file.
1 
47 #ifndef NZOS_TASK_H
48 #define NZOS_TASK_H
49 
50 #if (nzosTASK_ENABLE==1)
51 
52 //Task states
53 #define NZOS_TASKSTATE_BLOCKED 0
54 #define NZOS_TASKSTATE_READY 1
55 #define NZOS_TASKSTATE_RUNNING 2
56 #define NZOS_TASKSTATE_SUSPENDED 3
57 
61 #define nzTskStateBlockedToReady(pTCB) ((pTCB)->stateVal++)
62 
66 #define nzTskStateReadyToRunning(pTCB) ((pTCB)->stateVal++)
67 
68 
69 typedef struct NZOS_TCB_
70 //typedef struct __attribute__((__packed__)) NZOS_TCB_
71 //typedef struct __attribute__((aligned(2), packed)) NZOS_TCB_
72 {
73  //---- Header Begin, the same for Tasks, Fibers and "FSM Tasks" -----
74  //Blocked state
75  union {
76  struct
77  {
78  BYTE lsb;
79  BYTE msb;
80  } blocked;
81  WORD blockedVal;
82  };
83  void* pFunc; //Function Pointer
84  WORD funcParam; //Function Parameter
85  WORD_VAL param1;
86  WORD_VAL param2;
87  WORD timeout; //All Blocked and Running tasks have a timeout
88  BYTE sm;
89  //---- Header End -----
90  BYTE errNo; //Error number, 0=OK, else error code
91  BYTE priority; //Task priority, 0=lowest
92 
93  union {
94  struct
95  {
96  unsigned char val : 4;
97  unsigned char f1 : 1;
98  } state;
99  BYTE stateVal;
100  };
101 } NZOS_TCB;
102 
103 
105 
106 #endif //if (nzosTASK_ENABLE==1)
107 
108 #endif //#ifndef NZ_OS_H
109