📄 os_sem.ls1
字号:
A51 MACRO ASSEMBLER OS_SEM 08/08/2005 11:36:53 PAGE 1
MACRO ASSEMBLER A51 V7.10
OBJECT MODULE PLACED IN OS_SEM.OBJ
ASSEMBLER INVOKED BY: C:\Keil\C51\BIN\A51.EXE OS_SEM.src PR(.\OS_SEM.ls1) EP DEBUG
LOC OBJ LINE SOURCE
1 ; .\OS_SEM.SRC generated from: OS_SEM.C
2 ; COMPILER INVOKED BY:
3 ; C:\Keil\C51\BIN\C51.EXE OS_SEM.C LARGE BROWSE ORDER NOAREGS DEBUG OBJECTEXTEND SRC
(.\OS_SEM.SRC)
4
5 $nomod51
6
7 NAME OS_SEM
8
0080 9 P0 DATA 080H
0090 10 P1 DATA 090H
00A0 11 P2 DATA 0A0H
00B0 12 P3 DATA 0B0H
00D0 13 PSW DATA 0D0H
00E0 14 ACC DATA 0E0H
00F0 15 B DATA 0F0H
0081 16 SP DATA 081H
0082 17 DPL DATA 082H
0083 18 DPH DATA 083H
0087 19 PCON DATA 087H
0088 20 TCON DATA 088H
0089 21 TMOD DATA 089H
008A 22 TL0 DATA 08AH
008B 23 TL1 DATA 08BH
008C 24 TH0 DATA 08CH
008D 25 TH1 DATA 08DH
00A8 26 IE DATA 0A8H
00B8 27 IP DATA 0B8H
0098 28 SCON DATA 098H
0099 29 SBUF DATA 099H
00D7 30 CY BIT 0D0H.7
00D6 31 AC BIT 0D0H.6
00D5 32 F0 BIT 0D0H.5
00D4 33 RS1 BIT 0D0H.4
00D3 34 RS0 BIT 0D0H.3
00D2 35 OV BIT 0D0H.2
00D0 36 P BIT 0D0H.0
008F 37 TF1 BIT 088H.7
008E 38 TR1 BIT 088H.6
008D 39 TF0 BIT 088H.5
008C 40 TR0 BIT 088H.4
008B 41 IE1 BIT 088H.3
008A 42 IT1 BIT 088H.2
0089 43 IE0 BIT 088H.1
0088 44 IT0 BIT 088H.0
00AF 45 EA BIT 0A8H.7
00AC 46 ES BIT 0A8H.4
00AB 47 ET1 BIT 0A8H.3
00AA 48 EX1 BIT 0A8H.2
00A9 49 ET0 BIT 0A8H.1
00A8 50 EX0 BIT 0A8H.0
00BC 51 PS BIT 0B8H.4
00BB 52 PT1 BIT 0B8H.3
00BA 53 PX1 BIT 0B8H.2
00B9 54 PT0 BIT 0B8H.1
00B8 55 PX0 BIT 0B8H.0
00B7 56 RD BIT 0B0H.7
00B6 57 WR BIT 0B0H.6
A51 MACRO ASSEMBLER OS_SEM 08/08/2005 11:36:53 PAGE 2
00B5 58 T1 BIT 0B0H.5
00B4 59 T0 BIT 0B0H.4
00B3 60 INT1 BIT 0B0H.3
00B2 61 INT0 BIT 0B0H.2
00B1 62 TXD BIT 0B0H.1
00B0 63 RXD BIT 0B0H.0
009F 64 SM0 BIT 098H.7
009E 65 SM1 BIT 098H.6
009D 66 SM2 BIT 098H.5
009C 67 REN BIT 098H.4
009B 68 TB8 BIT 098H.3
009A 69 RB8 BIT 098H.2
0099 70 TI BIT 098H.1
0098 71 RI BIT 098H.0
72 ; /*
73 ; *****************************************************************************************
****************
74 ; * uC/OS-II
75 ; * The Real-Time Kernel
76 ; * SEMAPHORE MANAGEMENT
77 ; *
78 ; * (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
79 ; * All Rights Reserved
80 ; *
81 ; * File : OS_SEM.C
82 ; * By : Jean J. Labrosse
83 ; *****************************************************************************************
****************
84 ; */
85 ;
86 ; #ifndef OS_MASTER_FILE
87 ; #include "includes.h"
88 ; #endif
89 ;
90 ; #if OS_SEM_EN > 0
91 ; /*
92 ; *****************************************************************************************
****************
93 ; * ACCEPT SEMAPHORE
94 ; *
95 ; * Description: This function checks the semaphore to see if a resource is available or, i
f an event
96 ; * occurred. Unlike OSSemPend(), OSSemAccept() does not suspend the calling
task if the
97 ; * resource is not available or the event did not occur.
98 ; *
99 ; * Arguments : pevent is a pointer to the event control block
100 ; *
101 ; * Returns : > 0 if the resource is available or the event did not occur the sem
aphore is
102 ; * decremented to obtain the resource.
103 ; * == 0 if the resource is not available or the event did not occur or,
104 ; * if 'pevent' is a NULL pointer or,
105 ; * if you didn't pass a pointer to a semaphore
106 ; *****************************************************************************************
****************
107 ; */
108 ;
109 ; #if OS_SEM_ACCEPT_EN > 0
110 ; INT16U OSSemAccept (OS_EVENT *pevent)
111 ; {
112 ;
113 ; INT16U cnt;
114 ;
115 ;
116 ; #if OS_ARG_CHK_EN > 0
A51 MACRO ASSEMBLER OS_SEM 08/08/2005 11:36:53 PAGE 3
117 ; if (pevent == (OS_EVENT *)0) { /* Validate 'pevent'
*/
118 ; return (0);
119 ; }
120 ; if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type
*/
121 ; return (0);
122 ; }
123 ; #endif
124 ; OS_ENTER_CRITICAL();
125 ; cnt = pevent->OSEventCnt;
126 ; if (cnt > 0) { /* See if resource is available
*/
127 ; pevent->OSEventCnt--; /* Yes, decrement semaphore and not
ify caller */
128 ; }
129 ; OS_EXIT_CRITICAL();
130 ; return (cnt); /* Return semaphore count
*/
131 ; }
132 ; #endif
133 ;
134 ; /*$PAGE*/
135 ; /*
136 ; *****************************************************************************************
****************
137 ; * CREATE A SEMAPHORE
138 ; *
139 ; * Description: This function creates a semaphore.
140 ; *
141 ; * Arguments : cnt is the initial value for the semaphore. If the value is 0,
no resource is
142 ; * available (or no event has occurred). You initialize the se
maphore to a
143 ; * non-zero value to specify how many resources are available (
e.g. if you have
144 ; * 10 resources, you would initialize the semaphore to 10).
145 ; *
146 ; * Returns : != (void *)0 is a pointer to the event control clock (OS_EVENT) associate
d with the
147 ; * created semaphore
148 ; * == (void *)0 if no event control blocks were available
149 ; *****************************************************************************************
****************
150 ; */
151 ;
152 ; OS_EVENT *OSSemCreate (INT16U cnt)
153 ; {
154 ;
155 ; OS_EVENT *pevent;
156 ;
157 ;
158 ; if (OSIntNesting > 0) { /* See if called from ISR ...
*/
159 ; return ((OS_EVENT *)0); /* ... can't CREATE from an IS
R */
160 ; }
161 ; OS_ENTER_CRITICAL();
162 ; pevent = OSEventFreeList; /* Get next free event control
block */
163 ; if (OSEventFreeList != (OS_EVENT *)0) { /* See if pool of free ECB poo
l was empty */
164 ; OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
165 ; }
166 ; OS_EXIT_CRITICAL();
167 ; if (pevent != (OS_EVENT *)0) { /* Get an event control block
A51 MACRO ASSEMBLER OS_SEM 08/08/2005 11:36:53 PAGE 4
*/
168 ; pevent->OSEventType = OS_EVENT_TYPE_SEM;
169 ; pevent->OSEventCnt = cnt; /* Set semaphore value
*/
170 ; pevent->OSEventPtr = (void *)0; /* Unlink from ECB free list
*/
171 ; OS_EventWaitListInit(pevent); /* Initialize to 'nobody waiti
ng' on sem. */
172 ; }
173 ; return (pevent);
174 ; }
175 ;
176 ; /*$PAGE*/
177 ; /*
178 ; *****************************************************************************************
****************
179 ; * DELETE A SEMAPHORE
180 ; *
181 ; * Description: This function deletes a semaphore and readies all tasks pending on the sem
aphore.
182 ; *
183 ; * Arguments : pevent is a pointer to the event control block associated with the
desired
184 ; * semaphore.
185 ; *
186 ; * opt determines delete options as follows:
187 ; * opt == OS_DEL_NO_PEND Delete semaphore ONLY if no task pen
ding
188 ; * opt == OS_DEL_ALWAYS Deletes the semaphore even if tasks
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -