📄 semtest.lst
字号:
##############################################################################
# #
# IAR ARM ANSI C/C++ Compiler V4.30A/W32 KICKSTART 14/Dec/2005 14:41:47 #
# Copyright 1999-2005 IAR Systems. All rights reserved. #
# #
# Cpu mode = interwork #
# Endian = little #
# Stack alignment = 4 #
# Source file = D:\board\FreeRTOSV3.2.3\FreeRTOS\Demo\Common\Minimal #
# \semtest.c #
# Command line = D:\board\FreeRTOSV3.2.3\FreeRTOS\Demo\Common\Minimal #
# \semtest.c -D _NDEBUG -D STR71X_IAR -lC #
# D:\board\FreeRTOSV3.2.3\FreeRTOS\Demo\ARM7_STR71x_IA #
# R\binary\List\ --diag_suppress pe191,pa082 -o #
# D:\board\FreeRTOSV3.2.3\FreeRTOS\Demo\ARM7_STR71x_IA #
# R\binary\Obj\ -s9 --no_clustering --cpu_mode thumb #
# --endian little --cpu ARM7TDMI --stack_align 4 #
# --interwork -e --require_prototypes --fpu None #
# --dlib_config "C:\Program Files\IAR #
# Systems\Embedded Workbench 4.0 #
# Kickstart\arm\LIB\dl4tptinl8n.h" -I #
# D:\board\FreeRTOSV3.2.3\FreeRTOS\Demo\ARM7_STR71x_IA #
# R\ -I D:\board\FreeRTOSV3.2.3\FreeRTOS\Demo\ARM7_STR #
# 71x_IAR\library\include\ -I #
# D:\board\FreeRTOSV3.2.3\FreeRTOS\Demo\ARM7_STR71x_IA #
# R\..\common\include\ -I D:\board\FreeRTOSV3.2.3\Free #
# RTOS\Demo\ARM7_STR71x_IAR\..\..\source\include\ -I #
# "C:\Program Files\IAR Systems\Embedded Workbench #
# 4.0 Kickstart\arm\INC\" #
# List file = D:\board\FreeRTOSV3.2.3\FreeRTOS\Demo\ARM7_STR71x_IA #
# R\binary\List\semtest.lst #
# Object file = D:\board\FreeRTOSV3.2.3\FreeRTOS\Demo\ARM7_STR71x_IA #
# R\binary\Obj\semtest.r79 #
# #
# #
##############################################################################
D:\board\FreeRTOSV3.2.3\FreeRTOS\Demo\Common\Minimal\semtest.c
1 /*
2 FreeRTOS V3.2.3 - Copyright (C) 2003-2005 Richard Barry.
3
4 This file is part of the FreeRTOS distribution.
5
6 FreeRTOS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 FreeRTOS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with FreeRTOS; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 A special exception to the GPL can be applied should you wish to distribute
21 a combined work that includes FreeRTOS, without being obliged to provide
22 the source code for any proprietary components. See the licensing section
23 of http://www.FreeRTOS.org for full details of how and when the exception
24 can be applied.
25
26 ***************************************************************************
27 See http://www.FreeRTOS.org for documentation, latest information, license
28 and contact details. Please ensure to read the configuration and relevant
29 port sections of the online documentation.
30 ***************************************************************************
31 */
32
33 /*
34 * Creates two sets of two tasks. The tasks within a set share a variable, access
35 * to which is guarded by a semaphore.
36 *
37 * Each task starts by attempting to obtain the semaphore. On obtaining a
38 * semaphore a task checks to ensure that the guarded variable has an expected
39 * value. It then clears the variable to zero before counting it back up to the
40 * expected value in increments of 1. After each increment the variable is checked
41 * to ensure it contains the value to which it was just set. When the starting
42 * value is again reached the task releases the semaphore giving the other task in
43 * the set a chance to do exactly the same thing. The starting value is high
44 * enough to ensure that a tick is likely to occur during the incrementing loop.
45 *
46 * An error is flagged if at any time during the process a shared variable is
47 * found to have a value other than that expected. Such an occurrence would
48 * suggest an error in the mutual exclusion mechanism by which access to the
49 * variable is restricted.
50 *
51 * The first set of two tasks poll their semaphore. The second set use blocking
52 * calls.
53 *
54 */
55
56
57 #include <stdlib.h>
58
59 /* Scheduler include files. */
60 #include "FreeRTOS.h"
61 #include "task.h"
62 #include "semphr.h"
63
64 /* Demo app include files. */
65 #include "semtest.h"
66
67 /* The value to which the shared variables are counted. */
68 #define semtstBLOCKING_EXPECTED_VALUE ( ( unsigned portLONG ) 0xfff )
69 #define semtstNON_BLOCKING_EXPECTED_VALUE ( ( unsigned portLONG ) 0xff )
70
71 #define semtstSTACK_SIZE configMINIMAL_STACK_SIZE
72
73 #define semtstNUM_TASKS ( 4 )
74
75 #define semtstDELAY_FACTOR ( ( portTickType ) 10 )
76
77 /* The task function as described at the top of the file. */
78 static portTASK_FUNCTION_PROTO( prvSemaphoreTest, pvParameters );
79
80 /* Structure used to pass parameters to each task. */
81 typedef struct SEMAPHORE_PARAMETERS
82 {
83 xSemaphoreHandle xSemaphore;
84 volatile unsigned portLONG *pulSharedVariable;
85 portTickType xBlockTime;
86 } xSemaphoreParameters;
87
88 /* Variables used to check that all the tasks are still running without errors. */
\ In segment DATA_Z, align 4, align-sorted
89 static volatile portSHORT sCheckVariables[ semtstNUM_TASKS ] = { 0 };
\ ??sCheckVariables:
\ 00000000 DS8 8
\ In segment DATA_Z, align 2, align-sorted
90 static volatile portSHORT sNextCheckVariable = 0;
\ ??sNextCheckVariable:
\ 00000000 DS8 2
91
92 /*-----------------------------------------------------------*/
93
\ In segment CODE, align 4, keep-with-next
94 void vStartSemaphoreTasks( unsigned portBASE_TYPE uxPriority )
95 {
\ vStartSemaphoreTasks:
\ 00000000 70B5 PUSH {R4-R6,LR}
\ 00000002 041C MOV R4,R0
96 xSemaphoreParameters *pxFirstSemaphoreParameters, *pxSecondSemaphoreParameters;
97 const portTickType xBlockTime = ( portTickType ) 100;
98
99 /* Create the structure used to pass parameters to the first two tasks. */
100 pxFirstSemaphoreParameters = ( xSemaphoreParameters * ) pvPortMalloc( sizeof( xSemaphoreParameters ) );
\ 00000004 0C20 MOV R0,#+0xC
\ 00000006 ........ _BLF pvPortMalloc,pvPortMalloc??rT
\ 0000000A 061C MOV R6,R0
101
102 if( pxFirstSemaphoreParameters != NULL )
\ 0000000C 2D4D LDR R5,??vStartSemaphoreTasks_0 ;; ??prvSemaphoreTest
\ 0000000E 27D0 BEQ ??vStartSemaphoreTasks_1
103 {
104 /* Create the semaphore used by the first two tasks. */
105 vSemaphoreCreateBinary( pxFirstSemaphoreParameters->xSemaphore );
\ 00000010 0021 MOV R1,#+0
\ 00000012 0120 MOV R0,#+0x1
\ 00000014 ........ _BLF xQueueCreate,xQueueCreate??rT
\ 00000018 3060 STR R0,[R6, #+0]
\ 0000001A 0028 CMP R0,#+0
\ 0000001C 03D0 BEQ ??vStartSemaphoreTasks_2
\ 0000001E 0022 MOV R2,#+0
\ 00000020 0021 MOV R1,#+0
\ 00000022 ........ _BLF xQueueSend,xQueueSend??rT
106
107 if( pxFirstSemaphoreParameters->xSemaphore != NULL )
\ ??vStartSemaphoreTasks_2:
\ 00000026 3068 LDR R0,[R6, #+0]
\ 00000028 0028 CMP R0,#+0
\ 0000002A 19D0 BEQ ??vStartSemaphoreTasks_1
108 {
109 /* Create the variable which is to be shared by the first two tasks. */
110 pxFirstSemaphoreParameters->pulSharedVariable = ( unsigned portLONG * ) pvPortMalloc( sizeof( unsigned portLONG ) );
\ 0000002C 0420 MOV R0,#+0x4
\ 0000002E ........ _BLF pvPortMalloc,pvPortMalloc??rT
\ 00000032 7060 STR R0,[R6, #+0x4]
111
112 /* Initialise the share variable to the value the tasks expect. */
113 *( pxFirstSemaphoreParameters->pulSharedVariable ) = semtstNON_BLOCKING_EXPECTED_VALUE;
\ 00000034 FF21 MOV R1,#+0xFF
\ 00000036 0160 STR R1,[R0, #+0]
114
115 /* The first two tasks do not block on semaphore calls. */
116 pxFirstSemaphoreParameters->xBlockTime = ( portTickType ) 0;
\ 00000038 0020 MOV R0,#+0
\ 0000003A B060 STR R0,[R6, #+0x8]
117
118 /* Spawn the first two tasks. As they poll they operate at the idle priority. */
119 xTaskCreate( prvSemaphoreTest, "PolSEM1", semtstSTACK_SIZE, ( void * ) pxFirstSemaphoreParameters, tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );
\ 0000003C 01B4 PUSH {R0}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -