astroboy astroboy
/
CoOS_LWIP
Quick and dirty CoOS + LWIP ( Webserver )
CoOS/kernel/OsTask.h@0:94897d537b31, 2011-09-10 (annotated)
- Committer:
- astroboy
- Date:
- Sat Sep 10 22:41:10 2011 +0000
- Revision:
- 0:94897d537b31
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
astroboy | 0:94897d537b31 | 1 | /** |
astroboy | 0:94897d537b31 | 2 | ******************************************************************************* |
astroboy | 0:94897d537b31 | 3 | * @file OsTask.h |
astroboy | 0:94897d537b31 | 4 | * @version V1.1.4 |
astroboy | 0:94897d537b31 | 5 | * @date 2011.04.20 |
astroboy | 0:94897d537b31 | 6 | * @brief Header file related to task. |
astroboy | 0:94897d537b31 | 7 | * @details This file including some defines and function declare related to task. |
astroboy | 0:94897d537b31 | 8 | ******************************************************************************* |
astroboy | 0:94897d537b31 | 9 | * @copy |
astroboy | 0:94897d537b31 | 10 | * |
astroboy | 0:94897d537b31 | 11 | * INTERNAL FILE,DON'T PUBLIC. |
astroboy | 0:94897d537b31 | 12 | * |
astroboy | 0:94897d537b31 | 13 | * <h2><center>© COPYRIGHT 2009 CooCox </center></h2> |
astroboy | 0:94897d537b31 | 14 | ******************************************************************************* |
astroboy | 0:94897d537b31 | 15 | */ |
astroboy | 0:94897d537b31 | 16 | |
astroboy | 0:94897d537b31 | 17 | #ifndef _TASK_H |
astroboy | 0:94897d537b31 | 18 | #define _TASK_H |
astroboy | 0:94897d537b31 | 19 | |
astroboy | 0:94897d537b31 | 20 | #define SYS_TASK_NUM (1) /*!< System task number. */ |
astroboy | 0:94897d537b31 | 21 | |
astroboy | 0:94897d537b31 | 22 | /*---------------------------- Task Status -----------------------------------*/ |
astroboy | 0:94897d537b31 | 23 | #define TASK_READY 0 /*!< Ready status of task. */ |
astroboy | 0:94897d537b31 | 24 | #define TASK_RUNNING 1 /*!< Running status of task. */ |
astroboy | 0:94897d537b31 | 25 | #define TASK_WAITING 2 /*!< Waitting status of task. */ |
astroboy | 0:94897d537b31 | 26 | #define TASK_DORMANT 3 /*!< Dormant status of task. */ |
astroboy | 0:94897d537b31 | 27 | |
astroboy | 0:94897d537b31 | 28 | |
astroboy | 0:94897d537b31 | 29 | #define INVALID_ID (U8)0xff |
astroboy | 0:94897d537b31 | 30 | #define INVALID_VALUE (U32)0xffffffff |
astroboy | 0:94897d537b31 | 31 | #define MAGIC_WORD (U32)0x5a5aa5a5 |
astroboy | 0:94897d537b31 | 32 | |
astroboy | 0:94897d537b31 | 33 | |
astroboy | 0:94897d537b31 | 34 | /** |
astroboy | 0:94897d537b31 | 35 | * @struct TCB task.h |
astroboy | 0:94897d537b31 | 36 | * @brief Task control blcok. |
astroboy | 0:94897d537b31 | 37 | * @details This struct use to manage task. |
astroboy | 0:94897d537b31 | 38 | */ |
astroboy | 0:94897d537b31 | 39 | typedef struct TCB |
astroboy | 0:94897d537b31 | 40 | { |
astroboy | 0:94897d537b31 | 41 | OS_STK *stkPtr; /*!< The current point of task. */ |
astroboy | 0:94897d537b31 | 42 | U8 prio; /*!< Task priority. */ |
astroboy | 0:94897d537b31 | 43 | U8 state; /*!< TaSk status. */ |
astroboy | 0:94897d537b31 | 44 | OS_TID taskID; /*!< Task ID. */ |
astroboy | 0:94897d537b31 | 45 | |
astroboy | 0:94897d537b31 | 46 | #if CFG_MUTEX_EN > 0 |
astroboy | 0:94897d537b31 | 47 | OS_MutexID mutexID; /*!< Mutex ID. */ |
astroboy | 0:94897d537b31 | 48 | #endif |
astroboy | 0:94897d537b31 | 49 | |
astroboy | 0:94897d537b31 | 50 | #if CFG_EVENT_EN > 0 |
astroboy | 0:94897d537b31 | 51 | OS_EventID eventID; /*!< Event ID. */ |
astroboy | 0:94897d537b31 | 52 | #endif |
astroboy | 0:94897d537b31 | 53 | |
astroboy | 0:94897d537b31 | 54 | #if CFG_ROBIN_EN >0 |
astroboy | 0:94897d537b31 | 55 | U16 timeSlice; /*!< Task time slice */ |
astroboy | 0:94897d537b31 | 56 | #endif |
astroboy | 0:94897d537b31 | 57 | |
astroboy | 0:94897d537b31 | 58 | #if CFG_STK_CHECKOUT_EN >0 |
astroboy | 0:94897d537b31 | 59 | OS_STK *stack; /*!< The top point of task. */ |
astroboy | 0:94897d537b31 | 60 | #endif |
astroboy | 0:94897d537b31 | 61 | |
astroboy | 0:94897d537b31 | 62 | #if CFG_EVENT_EN > 0 |
astroboy | 0:94897d537b31 | 63 | void* pmail; /*!< Mail to task. */ |
astroboy | 0:94897d537b31 | 64 | struct TCB *waitNext; /*!< Point to next TCB in the Event waitting list.*/ |
astroboy | 0:94897d537b31 | 65 | struct TCB *waitPrev; /*!< Point to prev TCB in the Event waitting list.*/ |
astroboy | 0:94897d537b31 | 66 | #endif |
astroboy | 0:94897d537b31 | 67 | |
astroboy | 0:94897d537b31 | 68 | #if CFG_TASK_SCHEDULE_EN == 0 |
astroboy | 0:94897d537b31 | 69 | FUNCPtr taskFuc; |
astroboy | 0:94897d537b31 | 70 | OS_STK *taskStk; |
astroboy | 0:94897d537b31 | 71 | #endif |
astroboy | 0:94897d537b31 | 72 | |
astroboy | 0:94897d537b31 | 73 | |
astroboy | 0:94897d537b31 | 74 | #if CFG_FLAG_EN > 0 |
astroboy | 0:94897d537b31 | 75 | void* pnode; /*!< Pointer to node of event flag. */ |
astroboy | 0:94897d537b31 | 76 | #endif |
astroboy | 0:94897d537b31 | 77 | |
astroboy | 0:94897d537b31 | 78 | #if CFG_TASK_WAITTING_EN >0 |
astroboy | 0:94897d537b31 | 79 | U32 delayTick; /*!< The number of ticks which delay. */ |
astroboy | 0:94897d537b31 | 80 | #endif |
astroboy | 0:94897d537b31 | 81 | struct TCB *TCBnext; /*!< The pointer to next TCB. */ |
astroboy | 0:94897d537b31 | 82 | struct TCB *TCBprev; /*!< The pointer to prev TCB. */ |
astroboy | 0:94897d537b31 | 83 | |
astroboy | 0:94897d537b31 | 84 | }OSTCB,*P_OSTCB; |
astroboy | 0:94897d537b31 | 85 | |
astroboy | 0:94897d537b31 | 86 | |
astroboy | 0:94897d537b31 | 87 | /*---------------------------- Variable declare ------------------------------*/ |
astroboy | 0:94897d537b31 | 88 | // save tcb ptr that created |
astroboy | 0:94897d537b31 | 89 | extern P_OSTCB FreeTCB; /*!< A pointer to free TCB. */ |
astroboy | 0:94897d537b31 | 90 | extern OSTCB TCBTbl[CFG_MAX_USER_TASKS+SYS_TASK_NUM]; |
astroboy | 0:94897d537b31 | 91 | extern P_OSTCB TCBRdy; /*!< A pointer to TCB that is ready status */ |
astroboy | 0:94897d537b31 | 92 | extern P_OSTCB TCBNext; /*!< A pointer to TCB next be scheduled. */ |
astroboy | 0:94897d537b31 | 93 | extern P_OSTCB TCBRunning; /*!< A pointer to TCB that is running. */ |
astroboy | 0:94897d537b31 | 94 | |
astroboy | 0:94897d537b31 | 95 | extern U64 OSCheckTime; |
astroboy | 0:94897d537b31 | 96 | extern volatile U8 OSIntNesting; /*!< Use to indicate interrupt nesting level.*/ |
astroboy | 0:94897d537b31 | 97 | extern volatile U8 OSSchedLock; /*!< Schedule is lock(LOCK) or unlock(UN_LOCK).*/ |
astroboy | 0:94897d537b31 | 98 | extern volatile BOOL TaskSchedReq; |
astroboy | 0:94897d537b31 | 99 | extern OS_STK idle_stk[CFG_IDLE_STACK_SIZE]; |
astroboy | 0:94897d537b31 | 100 | |
astroboy | 0:94897d537b31 | 101 | |
astroboy | 0:94897d537b31 | 102 | void Schedule(void); /*!< Schedule function */ |
astroboy | 0:94897d537b31 | 103 | void IdleTask(void* pdata); /*!< IDLE task code */ |
astroboy | 0:94897d537b31 | 104 | void InsertToTCBRdyList (P_OSTCB tcbInser); |
astroboy | 0:94897d537b31 | 105 | void RemoveFromTCBRdyList(P_OSTCB ptcb); |
astroboy | 0:94897d537b31 | 106 | void CreateTCBList(void); |
astroboy | 0:94897d537b31 | 107 | #if CFG_ORDER_LIST_SCHEDULE_EN ==0 |
astroboy | 0:94897d537b31 | 108 | void ActiveTaskPri(U8 pri); |
astroboy | 0:94897d537b31 | 109 | void DeleteTaskPri(U8 pri); |
astroboy | 0:94897d537b31 | 110 | #endif |
astroboy | 0:94897d537b31 | 111 | |
astroboy | 0:94897d537b31 | 112 | #endif |