01.06.2013 Views

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Prior to making the RTX_TASK_CREATE API call, the caller must set the following members of the TaskDefBlock<br />

structure.<br />

proc<br />

name<br />

Here you must set the far vector to your task's entry point. The task's main procedure should be declared<br />

(depending on compiler used) as:<br />

Borland C: void huge taskfunc(void)<br />

Microsoft C: void far _saveregs _loadds taskfunc(void)<br />

These assure that the data segment register (DS) is loaded on entry into your task.<br />

Make up a four letter name for your task by which it can be uniquely identified. Avoid names already occupied<br />

by the systemtasks.<br />

stackptr<br />

This far pointer should point to the top of you task's stack space (highest address). Your tasks stack pointer will<br />

be initialized to this value, which points to the first byte of memory following your actual stack space. (Note that<br />

x86 CPU decrements the stack pointer prior to pushing data onto the stack.) The stack memory space resides<br />

within your application program.<br />

stacksize<br />

Here you specify the size of your task's stack space in bytes. The amount of stack space required for your task<br />

depends on the nature of your task. If large automatic objects are declared in your task's procedures, a large<br />

amount of stack space will be needed. Caution:<br />

Some of the system's interrupts use your task's stack. Consequently we recommend a minimum stack<br />

space of 1024 bytes per task.<br />

Since the problems resulting from stack overflow are often difficult to diagnose and analyze, the following<br />

design steps are recommended:<br />

1. Initially allocate way more stack space then you believe you will need.<br />

2. When you have your task performing what it was designed to do, measure the amount of stack space<br />

being used by your task. The RTX_GET_TASK_STATE API can be used to obtain this measurement.<br />

3. Refine your stack allocation based on this measurement, arriving at a compromise between the<br />

conflicting requirements: efficiency on the one hand (small stack desired) and program maintainability<br />

and reliability on the other hand (big stack desired).<br />

Software maintainability becomes an issue here if you have the stack space wired so tight that the slightest<br />

code change will lead to stack overflow. Reliability is an issue when paths in your task (or interrupts) are<br />

executed that did not execute during your stack space measurement trials.<br />

priority<br />

Application program tasks can range in priority from 3 to 127 (inclusive), where 3 is higher priority. Generally,<br />

task priorities between 20 and 30 are recommended. This recommendation is based on the priority<br />

assignments of the built-in systemtasks. Too high a priority for an application task may block important system<br />

tasks: e.g. the Ethernet receiver task. However, in some cases higher priority application tasks are appropriate<br />

design, but in these cases you must keep the execution dwell of these high priority task very short. User DOS<br />

applications are started at priority 25.<br />

Note:<br />

Internally all tasks have a unique priority. When a task is createdor its priority is changed, that task is<br />

given a lower internal task priority than any other task in the system with the same user task priority.<br />

time_slice<br />

Set this value to zero if you do not want round-robin time slicing between this task and others at the same<br />

priority level. If you do want round-robin switching, then specify here the number of milliseconds of CPU time<br />

that this task should receive before the system switches to the next task at this same priority. System timing<br />

granularity is one millisecond. Time slicing is disabled on all DOS application main tasks.<br />

mailboxlevelN<br />

These provisional four values are not used in the current implementation.<br />

Related Topics<br />

API function RTX_TASK_CREATE - Create and start a task<br />

Page 239 / 400

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

Saved successfully!

Ooh no, something went wrong!