Chapter 3
L3-7(2)
The task then sends a message to another task using the message queue AppQ.
In this case, the example shows a fixed message “1,” but the message could
have consisted of the address of a buffer, the address of a function, or whatever
would need to be sent.
L3-7(3)
The task then waits on the mutual exclusion semaphore since it needs to access
a shared resource with another task. If the resource is already owned by
another task, AppTask1() will wait forever for the mutex to be released by its
current owner. The forever wait is specified by passing 0 as the second
argument of the call.
L3-7(4)
When OSMutexPend() returns, the task owns the resource and can therefore
access the shared resource. The shared resource may be a variable, an array, a
data structure, an I/O device, etc.
L3-7(5)
When the task is done with the shared resource, it must call OSMutexPost() to
release the mutex.
static void AppTask2 (void *p_arg)
{
OS_ERR err;
void *p_msg;
OS_MSG_SIZE msg_size;
CPU_TS ts;
CPU_TS ts_delta;
p_arg = p_arg;
while (1) {
p_msg = OSQPend((OS_Q *)&AppQ,
(OS_MSG_SIZE *)&msg_size,
(OS_TICK )0,
(OS_OPT )OS_OPT_PEND_BLOCKING,
(CPU_TS *)&ts,
(OS_ERR *)&err);
ts_delta = OS_TS_GET() – ts;
/* Process message received */
(1)
(2)
(3)
}
}
Listing 3-8 APP.C (5th Part)
66
相关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