/* ******************* ******************************* C SOURCE FILE ******************************* ** ******************* ** ** ** ** project : The C Kernel ** ** filename : CKTCB.C ** ** version : 2 ** ** last revised : August 22, 2004 ** ** ** ***************************************************************************** ** ** ** Copyright (c) 1998-2004, P.K. van der Vlugt ** ** All rights reserved. ** ** ** ***************************************************************************** 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. */ #define _CKTCB_C_SRC /****************************************************************************/ /** **/ /** MODULES USED **/ /** **/ /****************************************************************************/ #include "cktcb.h" /****************************************************************************/ /** **/ /** DEFINITIONS AND MACROS **/ /** **/ /****************************************************************************/ /****************************************************************************/ /** **/ /** TYPEDEFS AND STRUCTURES **/ /** **/ /****************************************************************************/ /****************************************************************************/ /** **/ /** PROTOTYPES OF LOCAL FUNCTIONS **/ /** **/ /****************************************************************************/ static void init (int8u id); /****************************************************************************/ /** **/ /** EXPORTED VARIABLES **/ /** **/ /****************************************************************************/ TaskType Tcb[NR_OF_TASKS]; /****************************************************************************/ /** **/ /** GLOBAL VARIABLES **/ /** **/ /****************************************************************************/ /****************************************************************************/ /** **/ /** EXPORTED FUNCTIONS **/ /** **/ /****************************************************************************/ /****************************************************************************/ void TcbInit (void) /****************************************************************************/ { int8u id; /**** Initialize all id's ****/ for (id = 0; id < NR_OF_TASKS; id++) init (id); } /****************************************************************************/ int8u TcbAlloc (void) /****************************************************************************/ { int8u id; for (id = 0; id < NR_OF_TASKS; id++) { /**** Search for a free Id ****/ if (Tcb[id].state == TASK_FREE) { Tcb[id].state = TASK_REQUESTED; break; } } return (id); } /****************************************************************************/ void TcbFree (int8u id) /****************************************************************************/ { if (id >= NR_OF_TASKS) return; init (id); } /****************************************************************************/ /** **/ /** LOCAL FUNCTIONS **/ /** **/ /****************************************************************************/ /****************************************************************************/ static void init (int8u id) /****************************************************************************/ { Tcb[id].state = TASK_FREE; Tcb[id].prio = 0; Tcb[id].initprio = 0; Tcb[id].sdepth = 0; #if NR_OF_SEMAS > 0 Tcb[id].sid = NR_OF_SEMAS; #endif #if NR_OF_MBOXS > 0 && NR_OF_MSGS > 0 Tcb[id].mbid = NR_OF_MBOXS; #endif #if NR_OF_REGIONS > 0 Tcb[id].regions = 0; Tcb[id].raised = FALSE; Tcb[id].rid = NR_OF_REGIONS; #endif } /****************************************************************************/ /** **/ /** EOF **/ /** **/ /****************************************************************************/