/* ******************* ******************************* C HEADER FILE ******************************* ** ******************* ** ** ** ** project : The C Kernel ** ** filename : CKTCB.H ** ** version : 2 ** ** last revised : August 22, 2004 ** ** ** ***************************************************************************** ** ** ** Copyright (c) 1998-2004, P.K. van der Vlugt ** ** All rights reserved. ** ** ** ***************************************************************************** Task Control Block (TCB) Resource module. VERSION HISTORY: ---------------- Version : 1 Date : June 01, 2003 Revised by : P.K. van der Vlugt Description : Original version Version : 2 Date : August 22, 2004 Revised by : P.K. van der Vlugt Description : * Changed module name to comply to new kernel module naming convention. */ #ifndef _CKTCB_INCLUDED #define _CKTCB_INCLUDED /****************************************************************************/ /** **/ /** MODULES USED **/ /** **/ /****************************************************************************/ #include "ckconfig.h" /****************************************************************************/ /** **/ /** DEFINITIONS AND MACROS **/ /** **/ /****************************************************************************/ /****************************************************************************/ /** **/ /** TYPEDEFS AND STRUCTURES **/ /** **/ /****************************************************************************/ /**** Define the Task states ****/ typedef enum { TASK_FREE, /* TCB resource is free for allocation */ TASK_REQUESTED, /* TCB resource is allocated */ TASK_READY, /* Task is in READY state */ TASK_RUNNING, /* Task is in RUNNING state */ TASK_RECEIVE, /* Task is waiting on a mailbox */ TASK_SLEEP, /* Task is in SLEEP state */ TASK_SLEEP_SUSPEND, /* Task is SUSPENDED in SLEEP state */ TASK_SUSPEND, /* Task is in SUSPENDED state */ TASK_WAIT, /* Task is WAITING on a semaphore */ TASK_WAIT_REGION /* Task is waiting for a region */ } TaskStates; /**** Tcb Task type structure ****/ typedef struct { int8u state; /* Task current state, see above */ int8u prio; /* Task current priority */ int8u initprio; /* Task initial priority */ int8u sdepth; /* Suspension depth */ #if NR_OF_SEMAS > 0 int8u sid; /* Semaphore waiting for */ #endif #if NR_OF_MBOXS > 0 && NR_OF_MSGS > 0 int8u mbid; /* Mailbox receiving on */ int32u *msgptr; /* Message area to receive in */ #endif #if NR_OF_REGIONS > 0 int8u regions; /* Nr of regions locked by task */ bool raised; /* Task priority raised */ int8u rid; /* Region waiting for */ #endif } TaskType; /****************************************************************************/ /** **/ /** EXPORTED VARIABLES **/ /** **/ /****************************************************************************/ #ifndef _CKTCB_C_SRC extern TaskType Tcb[NR_OF_TASKS]; #endif /****************************************************************************/ /** **/ /** EXPORTED VARIABLES **/ /** **/ /****************************************************************************/ /****************************************************************************/ void TcbInit (void); /****************************************************************************/ /* * Initializes all resources in this module. This function must be called * before any other functions of this module are used. */ /****************************************************************************/ int8u TcbAlloc (void); /****************************************************************************/ /* * This function requests one of the available resources. If a resource * is available, the resource id will be returned. If there are no more * resources available, NR_OF_TASKS will be returned to indicate an error * situation. Other errors also return NR_OF_TASKS. */ /****************************************************************************/ void TcbFree (int8u id); /****************************************************************************/ /* * This function releases the specified resource id when it is a valid id. * The resource is set back to the initial state. */ #endif /****************************************************************************/ /** **/ /** EOF **/ /** **/ /****************************************************************************/