CooCox 1.1.4 on mbed with simple blinky example

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

task.c File Reference

task.c File Reference

task management implementation code of CooCox CoOS kernel. More...

Go to the source code of this file.

Functions

void CreateTCBList (void)
 Create a TCB list.
static BOOL GetPriSeqNum (U8 pri, OS_TID *SequenceNum)
 Get sequence number for Assign priority.
static U8 GetRdyPriSeqNum (U8 seqNum)
 Get the nearest ready priority sequence number for Assign number.
static void PrioRemap (OS_TID seqNum)
 Remap the ready status of priority queue from Assign sequence number.
static BOOL GetPrioSeqNumStatus (U8 seqNum)
 Get the ready status for assign sequence number.
static void SetPrioSeqNumStatus (U8 seqNum, BOOL isRdy)
 Set the ready status for assign sequence number.
void ActiveTaskPri (U8 pri)
 Active priority in queue.
void DeleteTaskPri (U8 pri)
 Delete priority in queue.
void InsertToTCBRdyList (P_OSTCB tcbInsert)
 Insert a task to the ready list.
void RemoveFromTCBRdyList (P_OSTCB ptcb)
 Remove a task from the READY list.
StatusType CoSetPriority (OS_TID taskID, U8 priority)
 Change task priority.
void Schedule (void)
 Schedule function.
static P_OSTCB AssignTCB (void)
 Assign a TCB to task being created.
OS_TID CreateTask (FUNCPtr task, void *argv, U32 parameter, OS_STK *stk)
 Create a task.
StatusType CoDelTask (OS_TID taskID)
 Delete Task.
void CoExitTask (void)
 Exit Task.
StatusType CoActivateTask (OS_TID taskID, void *argv)
 Activate Task.
OS_TID CoGetCurTaskID (void)
 Get current task id.
StatusType CoSuspendTask (OS_TID taskID)
 Suspend Task.
StatusType CoAwakeTask (OS_TID taskID)
 Awake Task.

Variables

OSTCB TCBTbl [CFG_MAX_USER_TASKS+SYS_TASK_NUM] = {{0}}
P_OSTCB FreeTCB = 0
P_OSTCB TCBRdy = 0
P_OSTCB TCBNext = 0
P_OSTCB TCBRunning = 0
U64 OSCheckTime = 0

Detailed Description

task management implementation code of CooCox CoOS kernel.

Version:
V1.1.4
Date:
2011.04.20

INTERNAL FILE,DON'T PUBLIC.

© COPYRIGHT 2009 CooCox

Definition in file task.c.


Function Documentation

void ActiveTaskPri ( U8  pri )

Active priority in queue.

Parameters:
[in]priTask priority
[in]None
[out]None
Return values:
None
Description

This function is called in Binary-Scheduling Algorithm to active priority in queue, if this priority had been in activation, increate the task num for this priority.

Definition at line 296 of file task.c.

static P_OSTCB AssignTCB ( void   ) [static]

Assign a TCB to task being created.

Parameters:
[in]None
[out]None
Return values:
XXXX
Description

This function is called to assign a task control block for task being created.

Definition at line 788 of file task.c.

StatusType CoActivateTask ( OS_TID  taskID,
void *  argv 
)

Activate Task.

Parameters:
[in]taskIDTask ID
[in]argvTask argv
[out]None
Return values:
E_INVALID_IDInvalid task ID.
E_OKActivate task successful.
Description

This function is called to activate current task.

Definition at line 1074 of file task.c.

StatusType CoAwakeTask ( OS_TID  taskID )

Awake Task.

Parameters:
[in]taskIDID of task that will been awaked.
[out]None
Return values:
E_OKTask awake successful.
E_INVALID_IDInvalid task ID.
E_TASK_NOT_WAITINGTask now not in waiting state.
E_TASK_WAIT_OTHERTask now waiting other awake event.
E_PROTECTED_TASKIdle task mustn't be awaked.
Description

This function is called to awake current task.

Definition at line 1198 of file task.c.

StatusType CoDelTask ( OS_TID  taskID )

Delete Task.

Parameters:
[in]taskIDTask ID
[out]None
Return values:
E_INVALID_IDInvalid task ID.
E_PROTECTED_TASKProtected task in OS.
E_OKDelete successful.
Description

This function is called to delete assign task.

Definition at line 946 of file task.c.

void CoExitTask ( void   )

Exit Task.

Parameters:
[in]None
[out]None
Return values:
None
Description

This function is called to exit current task.

Definition at line 1054 of file task.c.

OS_TID CoGetCurTaskID ( void   )

Get current task id.

Parameters:
[in]None
[out]None
Return values:
IDof the current task.
Description

This function is called to get current task id.

Definition at line 1116 of file task.c.

StatusType CoSetPriority ( OS_TID  taskID,
U8  priority 
)

Change task priority.

Parameters:
[in]taskIDSpecify task id.
[in]priorityNew priority.
[out]None
Return values:
E_OKChange priority successful.
E_INVALID_IDInvalid id,change priority fail.
E_PROTECTED_TASKCan't change idle task priority.
Description

This function is called to change priority for a specify task.

Definition at line 575 of file task.c.

StatusType CoSuspendTask ( OS_TID  taskID )

Suspend Task.

Parameters:
[in]taskIDID of task that want to suspend.
[out]None
Return values:
E_OKTask suspend successful.
E_INVALID_IDInvalid event ID.
E_PROTECTED_TASKCan't suspend idle task.
E_ALREADY_IN_WAITINGTask now in waiting state.
Description

This function is called to exit current task.

Definition at line 1137 of file task.c.

OS_TID CreateTask ( FUNCPtr  task,
void *  argv,
U32  parameter,
OS_STK *  stk 
)

Create a task.

Parameters:
[in]taskTask code entry.
[in]argvThe parameter passed to task.
[in]parameterTask priority + stack size + time slice + isWaitting.
[in]stkPointer to stack top of task.
[out]None
Return values:
E_CREATE_FAILFail to create a task .
othersValid task id.
Description

This function is called by application to create a task,return a id to mark this task.

Definition at line 822 of file task.c.

void CreateTCBList ( void   )

Create a TCB list.

Parameters:
[in]None
[out]None
Return values:
None
Description

This function is called by CoOSInit() to initial the empty list of OS_TCBS,supply a pointer to free TCB.

Definition at line 55 of file task.c.

void DeleteTaskPri ( U8  pri )

Delete priority in queue.

Parameters:
[in]priTask priority
[in]None
[out]None
Return values:
None
Description

This function is called in Binary-Scheduling Algorithm to decrease the task num for this priority, if the num goto 0, remove the priority for queue.

Definition at line 335 of file task.c.

static BOOL GetPrioSeqNumStatus ( U8  seqNum ) [static]

Get the ready status for assign sequence number.

Parameters:
[in]seqNumAssign sequence number
[out]None
Return values:
Co_TRUEThis priority has ready task Co_FALSE This priority doesn't have ready task
Description

This function is called in Binary-Scheduling Algorithm to get the ready status for assign sequence number.

Definition at line 249 of file task.c.

static BOOL GetPriSeqNum ( U8  pri,
OS_TID *  SequenceNum 
) [static]

Get sequence number for Assign priority.

Parameters:
[in]priAssign priority
[out]SequenceNumpriority number
Return values:
Co_TRUEAssign priority in priority queue. Co_FALSE Assign priority not in priority queue.
Description

This function is called in Binary-Scheduling Algorithm to get sequence number for Assign priority.

Definition at line 104 of file task.c.

static U8 GetRdyPriSeqNum ( U8  seqNum ) [static]

Get the nearest ready priority sequence number for Assign number.

Parameters:
[in]seqNumAssign sequence number
[out]None
Return values:
INVALID_IDCannot find higher ready priority. Others Nearest ready priority sequence number
Description

This function is called in Binary-Scheduling Algorithm to get the nearest ready priority sequence number.

Definition at line 147 of file task.c.

void InsertToTCBRdyList ( P_OSTCB  tcbInsert )

Insert a task to the ready list.

Parameters:
[in]tcbInsertA pointer to task will be inserted.
[out]None
Return values:
None
Description

This function is called to insert a task to the READY list.

Definition at line 368 of file task.c.

static void PrioRemap ( OS_TID  seqNum ) [static]

Remap the ready status of priority queue from Assign sequence number.

Parameters:
[in]seqNumAssign sequence number
[out]None
Return values:
None
Description

This function is called in Binary-Scheduling Algorithm to Remap the ready status for priority queue.

Definition at line 208 of file task.c.

void RemoveFromTCBRdyList ( P_OSTCB  ptcb )

Remove a task from the READY list.

Parameters:
[in]ptcbA pointer to task which be removed.
[out]None
Return values:
None
Description

This function is called to remove a task from the READY list.

Definition at line 491 of file task.c.

void Schedule ( void   )

Schedule function.

Parameters:
[in]None
[out]None
Return values:
None
Description

This function is called by every where need to switch context, It is schedule function of OS kernel.

Definition at line 710 of file task.c.

static void SetPrioSeqNumStatus ( U8  seqNum,
BOOL  isRdy 
) [static]

Set the ready status for assign sequence number.

Parameters:
[in]seqNumAssign sequence number
[in]isRdyReady statues for assign sequence number
[out]None
Return values:
None
Description

This function is called in Binary-Scheduling Algorithm to set the ready status for assign sequence number.

Definition at line 272 of file task.c.


Variable Documentation

pointer to free TCB

Definition at line 28 of file task.c.

U64 OSCheckTime = 0

The counter of system tick.

Definition at line 32 of file task.c.

Poniter to task that next scheduled by OS

Definition at line 30 of file task.c.

Pointer to the READY list.

Definition at line 29 of file task.c.

Pointer to TCB that current running task.

Definition at line 31 of file task.c.

OSTCB TCBTbl[CFG_MAX_USER_TASKS+SYS_TASK_NUM] = {{0}}

< Table use to save TCB pointer. The stack of IDLE task.

Definition at line 23 of file task.c.