02.01.2015 Views

CooCox CoOS User's Guide

CooCox CoOS User's Guide

CooCox CoOS User's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

#include "CCRTOS.h"<br />

#define TASKM_PRIO 11<br />

#define TASKM_STK_SIZE 100<br />

#define TASKM_TIME_SLICE 10<br />

OS_STK TaskMStk[TASKMSTKSIZE];<br />

OS_TID TaskMId;<br />

void TaskM (void *pdata);<br />

void TaskN (void *pdata)<br />

{<br />

...<br />

TaskMId = CoCreateTaskEx(TaskM,<br />

(void *)0,<br />

TASKM_PRIO,<br />

&TaskMStk[TASKM_STK_SIZE-1],<br />

TASKM_STK_SIZE,<br />

TASKM_TIME_SLICE,<br />

FASLE);<br />

if (TaskMID==E_CREATE_FAIL)<br />

{<br />

printf("Task Create Failed !\n");<br />

}<br />

else<br />

{<br />

printf("Task ID %d\n",TaskMId);<br />

}<br />

...<br />

}<br />

void TaskM (void *pdata)<br />

{<br />

...<br />

}<br />

Note:<br />

1) A relevant PCB is distributed when a task is created.<br />

2) A task is in the ready state once being successfully created.<br />

3) If the priority of the current created task is higher than the running<br />

task, the system start a task scheduling and distribute the execution<br />

time to the current task.<br />

4) The maximum stkSz is 0xfff, the maximum timeSlice is 0xfff.<br />

6.2.2 CoExitTask()<br />

Function Prototype:<br />

50

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!