⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_sem.ls1

📁 在51单片机上移植成功的UCOS-II操作系统源代码,包括源代码及相关注释
💻 LS1
📖 第 1 页 / 共 2 页
字号:
A51 MACRO ASSEMBLER  OS_SEM                                                               09/09/2007 21:13:34 PAGE     1


MACRO ASSEMBLER A51 V7.10
OBJECT MODULE PLACED IN OS_SEM.OBJ
ASSEMBLER INVOKED BY: D:\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     ;        D:\Keil\C51\BIN\C51.EXE OS_SEM.C LARGE BROWSE 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
  00B4                13     T0      BIT     0B0H.4
  00D6                14     AC      BIT     0D0H.6
  00B5                15     T1      BIT     0B0H.5
  00AF                16     EA      BIT     0A8H.7
  00A8                17     IE      DATA    0A8H
  00B7                18     RD      BIT     0B0H.7
  00AC                19     ES      BIT     0A8H.4
  00B8                20     IP      DATA    0B8H
  0098                21     RI      BIT     098H.0
  00B2                22     INT0    BIT     0B0H.2
  00D7                23     CY      BIT     0D0H.7
  0099                24     TI      BIT     098H.1
  00B3                25     INT1    BIT     0B0H.3
  00BC                26     PS      BIT     0B8H.4
  0081                27     SP      DATA    081H
  00D2                28     OV      BIT     0D0H.2
  00B6                29     WR      BIT     0B0H.6
  0099                30     SBUF    DATA    099H
  0087                31     PCON    DATA    087H
  0098                32     SCON    DATA    098H
  0089                33     TMOD    DATA    089H
  0088                34     TCON    DATA    088H
  0089                35     IE0     BIT     088H.1
  008B                36     IE1     BIT     088H.3
  00F0                37     B       DATA    0F0H
  00E0                38     ACC     DATA    0E0H
  00A9                39     ET0     BIT     0A8H.1
  00AB                40     ET1     BIT     0A8H.3
  008D                41     TF0     BIT     088H.5
  008F                42     TF1     BIT     088H.7
  009A                43     RB8     BIT     098H.2
  008C                44     TH0     DATA    08CH
  00A8                45     EX0     BIT     0A8H.0
  0088                46     IT0     BIT     088H.0
  008D                47     TH1     DATA    08DH
  009B                48     TB8     BIT     098H.3
  00AA                49     EX1     BIT     0A8H.2
  008A                50     IT1     BIT     088H.2
  00D0                51     P       BIT     0D0H.0
  009F                52     SM0     BIT     098H.7
  008A                53     TL0     DATA    08AH
  009E                54     SM1     BIT     098H.6
  008B                55     TL1     DATA    08BH
  009D                56     SM2     BIT     098H.5
  00B9                57     PT0     BIT     0B8H.1
  00BB                58     PT1     BIT     0B8H.3
A51 MACRO ASSEMBLER  OS_SEM                                                               09/09/2007 21:13:34 PAGE     2

  00D3                59     RS0     BIT     0D0H.3
  008C                60     TR0     BIT     088H.4
  00D4                61     RS1     BIT     0D0H.4
  008E                62     TR1     BIT     088H.6
  00B8                63     PX0     BIT     0B8H.0
  00BA                64     PX1     BIT     0B8H.2
  0083                65     DPH     DATA    083H
  0082                66     DPL     DATA    082H
  009C                67     REN     BIT     098H.4
  00B0                68     RXD     BIT     0B0H.0
  00B1                69     TXD     BIT     0B0H.1
  00D5                70     F0      BIT     0D0H.5
  00D0                71     PSW     DATA    0D0H
                      72     ; /*
                      73     ; *****************************************************************************************
                             ****************
                      74     ; *                                                uC/OS-II
                      75     ; *                                          The Real-Time Kernel
                      76     ; *                                          SEMAPHORE MANAGEMENT
                      77     ; *
                      78     ; *                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
                      79     ; *                                           All Rights Reserved
                      80     ; *
                      81     ; *                                                  V2.00
                      82     ; *
                      83     ; * File : OS_SEM.C
                      84     ; * By   : Jean J. Labrosse
                      85     ; *****************************************************************************************
                             ****************
                      86     ; */
                      87     ; 
                      88     ; #ifndef  OS_MASTER_FILE
                      89     ; #include "includes.h"
                      90     ; #endif
                      91     ; 
                      92     ; #if OS_SEM_EN
                      93     ; /*
                      94     ; *****************************************************************************************
                             ****************
                      95     ; *                                           ACCEPT SEMAPHORE
                      96     ; *
                      97     ; * Description: This function checks the semaphore to see if a resource is available or, i
                             f an event
                      98     ; *              occurred.  Unlike OSSemPend(), OSSemAccept() does not suspend the calling 
                             task if the
                      99     ; *              resource is not available or the event did not occur.
                     100     ; *
                     101     ; * Arguments  : pevent     is a pointer to the event control block
                     102     ; *
                     103     ; * Returns    : >  0       if the resource is available or the event did not occur the sem
                             aphore is
                     104     ; *                         decremented to obtain the resource.
                     105     ; *              == 0       if the resource is not available or the event did not occur or,
                     106     ; *                         you didn't pass a pointer to a semaphore
                     107     ; *****************************************************************************************
                             ****************
                     108     ; */
                     109     ; 
                     110     ; INT16U OSSemAccept (OS_EVENT *pevent) reentrant
                     111     ; {
                     112     ;     INT16U cnt;
                     113     ; 
                     114     ; 
                     115     ;     OS_ENTER_CRITICAL();
                     116     ;     if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type       
                                           */
A51 MACRO ASSEMBLER  OS_SEM                                                               09/09/2007 21:13:34 PAGE     3

                     117     ;         OS_EXIT_CRITICAL();
                     118     ;         return (0);
                     119     ;     }
                     120     ;     cnt = pevent->OSEventCnt;
                     121     ;     if (cnt > 0) {                                    /* See if resource is available    
                                           */
                     122     ;         pevent->OSEventCnt--;                         /* Yes, decrement semaphore and not
                             ify caller    */
                     123     ;     }
                     124     ;     OS_EXIT_CRITICAL();
                     125     ;     return (cnt);                                     /* Return semaphore count          
                                           */
                     126     ; }
                     127     ; 
                     128     ; /*$PAGE*/
                     129     ; /*
                     130     ; *****************************************************************************************
                             ****************
                     131     ; *                                           CREATE A SEMAPHORE
                     132     ; *
                     133     ; * Description: This function creates a semaphore.
                     134     ; *
                     135     ; * Arguments  : cnt           is the initial value for the semaphore.  If the value is 0, 
                             no resource is
                     136     ; *                            available (or no event has occurred).  You initialize the se
                             maphore to a 
                     137     ; *                            non-zero value to specify how many resources are available (
                             e.g. if you have
                     138     ; *                            10 resources, you would initialize the semaphore to 10).
                     139     ; *
                     140     ; * Returns    : != (void *)0  is a pointer to the event control clock (OS_EVENT) associate
                             d with the
                     141     ; *                            created semaphore
                     142     ; *              == (void *)0  if no event control blocks were available
                     143     ; *****************************************************************************************
                             ****************
                     144     ; */
                     145     ; 
                     146     ; OS_EVENT *OSSemCreate (INT16U cnt) reentrant
                     147     ; {
                     148     ;     OS_EVENT *pevent;
                     149     ; 
                     150     ; 
                     151     ;     OS_ENTER_CRITICAL();
                     152     ;     pevent = OSEventFreeList;                              /* Get next free event control
                              block        */
                     153     ;     if (OSEventFreeList != (OS_EVENT *)0) {                /* See if pool of free ECB poo
                             l was empty   */
                     154     ;         OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
                     155     ;     }
                     156     ;     OS_EXIT_CRITICAL();
                     157     ;     if (pevent != (OS_EVENT *)0) {                         /* Get an event control block 
                                           */
                     158     ;         pevent->OSEventType = OS_EVENT_TYPE_SEM;
                     159     ;         pevent->OSEventCnt  = cnt;                         /* Set semaphore value        
                                           */
                     160     ;         OSEventWaitListInit(pevent);
                     161     ;     }
                     162     ;     return (pevent);
                     163     ; }
                     164     ; 
                     165     ; /*$PAGE*/
                     166     ; /*
                     167     ; *****************************************************************************************
                             ****************
                     168     ; *                                           PEND ON SEMAPHORE
A51 MACRO ASSEMBLER  OS_SEM                                                               09/09/2007 21:13:34 PAGE     4

                     169     ; *
                     170     ; * Description: This function waits for a semaphore.
                     171     ; *
                     172     ; * Arguments  : pevent        is a pointer to the event control block associated with the 
                             desired 
                     173     ; *                            semaphore.
                     174     ; *
                     175     ; *              timeout       is an optional timeout period (in clock ticks).  If non-zero
                             , your task will
                     176     ; *                            wait for the resource up to the amount of time specified by 
                             this argument.  
                     177     ; *                            If you specify 0, however, your task will wait forever at th
                             e specified 
                     178     ; *                            semaphore or, until the resource becomes available (or the e
                             vent occurs).
                     179     ; *
                     180     ; *              err           is a pointer to where an error message will be deposited.  P
                             ossible error
                     181     ; *                            messages are:
                     182     ; *
                     183     ; *                            OS_NO_ERR          The call was successful and your task own
                             s the resource 
                     184     ; *                                               or, the event you are waiting for occurre
                             d.
                     185     ; *                            OS_TIMEOUT         The semaphore was not received within the
                              specified 
                     186     ; *                                               timeout.
                     187     ; *                            OS_ERR_EVENT_TYPE  If you didn't pass a pointer to a semapho
                             re.
                     188     ; *                            OS_ERR_PEND_ISR    If you called this function from an ISR a
                             nd the result
                     189     ; *                                               would lead to a suspension.
                     190     ; *
                     191     ; * Returns    : none

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -