Task Management
5-6-1 THE IDLE TASK ( OS_IdleTask() )
OS_IdleTask() is the very first task created by μC/OS-III and always exists in a μC/OS-III-
based application. The priority of the idle task is always set to OS_CFG_PRIO_MAX-1 . In fact,
OS_IdleTask() is the only task that is ever allowed to be at this priority and, as a
safeguard, when other tasks are created, OSTaskCreate() ensures that there are no other
tasks created at the same priority as the idle task. The idle task runs whenever there are no
other tasks that are ready to run. The important portions of the code for the idle task are
shown below (refer to OS_CORE.C for the complete code).
void OS_IdleTask (void *p_arg)
{
while (DEF_ON) {
OS_CRITICAL_ENTER();
OSIdleTaskCtr++;
OSTaskStatCtr++;
OS_CRITICAL_EXIT();
OSIdleTaskHook();
(1)
(2)
(3)
}
}
Listing 5-4 Idle Task
L5-4(1)
The idle task is a “true” infinite loop that never calls functions to “wait for an
event”. This is because, on most processors, when there is “nothing to do,” the
processor still executes instructions. When μC/OS-III determines that there is
no other higher-priority task to run, μC/OS-III “parks” the CPU in the idle task.
Instead of having an empty “for loop” doing nothing, this “idle” time is used to
do something useful.
L5-4(2)
Two counters are incremented whenever the idle task runs.
OSIdleTaskCtr is typically defined as a 32-bit unsigned integer (see OS.H ).
OSIdleTaskCtr is reset once when μC/OS-III is initialized. OSIdleTaskCtr is
used to indicate “activity” in the idle task. In other words, if one monitors and
displays OSIdleTaskCtr , one should expect to see a value between
0x00000000 and 0xFFFFFFFF . The rate at which OSIdleTaskCtr increments
depend on how busy the CPU is at running the application code. The faster the
increment, the less work the CPU has to do in application tasks.
107
相关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