Task Management
the ASCII string to parse and what constitute tokens. As soon as the function finds the first
token, it returns. The function “remembers” where it was last so when called again, it can
extract additional tokens, which is clearly non-reentrant.
The use of an infinite loop is more common in embedded systems because of the repetitive
work needed in such systems (reading inputs, updating displays, performing control
operations, etc.). This is one aspect that makes a task different than a regular C function.
Note that one could use a “ while (1) ” or “ for (;;) ” to implement the infinite loop, since
both behave the same. The one used is simply a matter of personal preference. At Micrium,
we like to use “ while (DEF_ON) ”. The infinite loop must call a μC/OS-III service (i.e.,
function) that will cause the task to wait for an event to occur. It is important that each task
wait for an event to occur, otherwise the task would be a true infinite loop and there would
be no easy way for other tasks to execute. This concept will become clear as more is
understood regarding μC/OS-III.
void MyTask (void *p_arg)
{
/* Local variables
/* Do something with “p_arg”
/* Task initialization
while (DEF_ON) { /* Task body, as an infinite loop.
:
/* Task body ... do work!
:
/* Must call one of the following services:
/* OSFlagPend()
/* OSMutexPend()
/* OSPendMulti()
/* OSQPend()
/* OSSemPend()
/* OSTimeDly()
/* OSTimeDlyHMSM()
/* OSTaskQPend()
/* OSTaskSemPend()
/* OSTaskSuspend() (Suspend self)
/* OSTaskDel() (Delete self)
:
/* Task body ... do work!
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
:
}
}
Listing 5-2 Infinite Loop task
77
相关PDF资料
AD-UCUSBD-SPRD PRD LIC UCUSB DEV CORE CCES SGL
AD637-EVALZ BOARD EVALUATION FOR AD637
AD736-EVALZ BOARD EVALUATION FOR AD736
AD737-EVALZ BOARD EVALUATION FOR AD737
AD8007AKS-EBZ BOARD EVAL FOR AD8007AKS
AD8018ARU-EVAL BOARD EVAL FOR AD8018
AD8034ART-EBZ BOARD EVAL FOR AD8034ART
AD8040AR-EBZ BOARD EVAL FOR AD8040AR
相关代理商/技术参数
ADUCOSC100 制造商:Analog Devices 功能描述:ADC - Rail/Tube
ADUCOSC100-REEL 功能描述:DAC MICROCONVERTER DUAL TSSOP 制造商:analog devices inc. 系列:* 零件状态:上次购买时间 标准包装:1
ADUCOSC100-REEL7 功能描述:DAC MICROCONVERTER DUAL TSSOP 制造商:analog devices inc. 系列:* 零件状态:上次购买时间 标准包装:1
ADUCOSCZ100 制造商:Analog Devices 功能描述:
ADUCOSCZ100-REEL7 制造商:Analog Devices 功能描述:ANAADUCOSCZ100-REEL7 12 BIT ADC WITH EMB
ADuC-P7026 功能描述:开发板和工具包 - ARM PROTOTYPE BRD FOR ADUC7026 ARM7 RoHS:否 制造商:Arduino 产品:Development Boards 工具用于评估:ATSAM3X8EA-AU 核心:ARM Cortex M3 接口类型:DAC, ICSP, JTAG, UART, USB 工作电源电压:3.3 V
ADUCRF101 制造商:Analog Devices 功能描述:PRECISION ANALOG MICRCONTROLLER - Tape and Reel
ADUCRF101BCPZ128 制造商:Analog Devices 功能描述:PRECISION ANALOG MICROCONTROLLER WITH RF TRANSCEIVER, ARM CO - Trays