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

📄 os_mutex.ls1

📁 uCOS-II_2.52在51上的移植程序
💻 LS1
📖 第 1 页 / 共 4 页
字号:
A51 MACRO ASSEMBLER  OS_MUTEX                                                             08/08/2005 11:36:49 PAGE     1


MACRO ASSEMBLER A51 V7.10
OBJECT MODULE PLACED IN OS_MUTEX.OBJ
ASSEMBLER INVOKED BY: C:\Keil\C51\BIN\A51.EXE OS_MUTEX.src PR(.\OS_MUTEX.ls1) EP DEBUG

LOC  OBJ            LINE     SOURCE

                       1     ; .\OS_MUTEX.SRC generated from: OS_MUTEX.C
                       2     ; COMPILER INVOKED BY:
                       3     ;        C:\Keil\C51\BIN\C51.EXE OS_MUTEX.C LARGE BROWSE ORDER NOAREGS DEBUG OBJECTEXTEND S
                             RC(.\OS_MUTEX.SRC)
                       4     
                       5     $nomod51 
                       6     
                       7     NAME    OS_MUTEX
                       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_MUTEX                                                             08/08/2005 11:36:49 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     ; *                                  MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
                      77     ; *
                      78     ; *                          (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
                      79     ; *                                           All Rights Reserved
                      80     ; *
                      81     ; * File : OS_MUTEX.C
                      82     ; * By   : Jean J. Labrosse
                      83     ; *****************************************************************************************
                             ****************
                      84     ; */
                      85     ; 
                      86     ; #ifndef  OS_MASTER_FILE
                      87     ; #include "includes.h"
                      88     ; #endif
                      89     ; 
                      90     ; /*
                      91     ; *****************************************************************************************
                             ****************
                      92     ; *                                            LOCAL CONSTANTS
                      93     ; *****************************************************************************************
                             ****************
                      94     ; */
                      95     ; 
                      96     ; #define  OS_MUTEX_KEEP_LOWER_8   0x00FF
                      97     ; #define  OS_MUTEX_KEEP_UPPER_8   0xFF00
                      98     ; 
                      99     ; #define  OS_MUTEX_AVAILABLE      0x00FF
                     100     ; 
                     101     ; 
                     102     ; #if OS_MUTEX_EN > 0
                     103     ; /*
                     104     ; *****************************************************************************************
                             ****************
                     105     ; *                                   ACCEPT MUTUAL EXCLUSION SEMAPHORE
                     106     ; *
                     107     ; * Description: This  function checks the mutual exclusion semaphore to see if a resource 
                             is available.
                     108     ; *              Unlike OSMutexPend(), OSMutexAccept() does not suspend the calling task if
                              the resource is
                     109     ; *              not available or the event did not occur.
                     110     ; *
                     111     ; * Arguments  : pevent     is a pointer to the event control block
                     112     ; *
                     113     ; *              err        is a pointer to an error code which will be returned to your ap
                             plication:
                     114     ; *                            OS_NO_ERR          if the call was successful.
                     115     ; *                            OS_ERR_EVENT_TYPE  if 'pevent' is not a pointer to a mutex
A51 MACRO ASSEMBLER  OS_MUTEX                                                             08/08/2005 11:36:49 PAGE     3

                     116     ; *                            OS_ERR_PEVENT_NULL 'pevent' is a NULL pointer
                     117     ; *                            OS_ERR_PEND_ISR     if you called this function from an ISR
                     118     ; *
                     119     ; * Returns    : == 1       if the resource is available, the mutual exclusion semaphore is
                              acquired
                     120     ; *              == 0       a) if the resource is not available
                     121     ; *                         b) you didn't pass a pointer to a mutual exclusion semaphore
                     122     ; *                         c) you called this function from an ISR
                     123     ; *
                     124     ; * Warning(s) : This function CANNOT be called from an ISR because mutual exclusion semaph
                             ores are
                     125     ; *              intended to be used by tasks only.
                     126     ; *****************************************************************************************
                             ****************
                     127     ; */
                     128     ; 
                     129     ; #if OS_MUTEX_ACCEPT_EN > 0
                     130     ; INT8U  OSMutexAccept (OS_EVENT *pevent, INT8U *err)
                     131     ; {
                     132     ;   
                     133     ;     
                     134     ;     
                     135     ;     if (OSIntNesting > 0) {                            /* Make sure it's not called from 
                             an ISR        */
                     136     ;         *err = OS_ERR_PEND_ISR;
                     137     ;         return (0);
                     138     ;     }
                     139     ; #if OS_ARG_CHK_EN > 0
                     140     ;     if (pevent == (OS_EVENT *)0) {                     /* Validate 'pevent'              
                                           */
                     141     ;         *err = OS_ERR_PEVENT_NULL;
                     142     ;         return (0);
                     143     ;     }
                     144     ;     if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) {  /* Validate event block type      
                                           */
                     145     ;         *err = OS_ERR_EVENT_TYPE;
                     146     ;         return (0);
                     147     ;     }
                     148     ; #endif                                                     
                     149     ;     OS_ENTER_CRITICAL();                                                         /* Get v
                             alue (0 or 1) of Mutex                  */
                     150     ;     if ((pevent->OSEventCnt & OS_MUTEX_KEEP_LOWER_8) == OS_MUTEX_AVAILABLE) {     
                     151     ;         pevent->OSEventCnt &= OS_MUTEX_KEEP_UPPER_8;   /*      Mask off LSByte (Acquire M
                             utex)         */
                     152     ;         pevent->OSEventCnt |= OSTCBCur->OSTCBPrio;     /*      Save current task priority
                              in LSByte    */
                     153     ;         pevent->OSEventPtr  = (void *)OSTCBCur;        /*      Link TCB of task owning Mu
                             tex           */
                     154     ;         OS_EXIT_CRITICAL();
                     155     ;         *err = OS_NO_ERR;
                     156     ;         return (1);
                     157     ;     }
                     158     ;     OS_EXIT_CRITICAL();
                     159     ;     *err = OS_NO_ERR;
                     160     ;     return (0);
                     161     ; }
                     162     ; #endif                                                     
                     163     ; 
                     164     ; /*$PAGE*/
                     165     ; /*
                     166     ; *****************************************************************************************
                             ****************
                     167     ; *                                  CREATE A MUTUAL EXCLUSION SEMAPHORE
                     168     ; *
                     169     ; * Description: This function creates a mutual exclusion semaphore.
                     170     ; *
A51 MACRO ASSEMBLER  OS_MUTEX                                                             08/08/2005 11:36:49 PAGE     4

                     171     ; * Arguments  : prio          is the priority to use when accessing the mutual exclusion s
                             emaphore.  In
                     172     ; *                            other words, when the semaphore is acquired and a higher pri
                             ority task
                     173     ; *                            attempts to obtain the semaphore then the priority of the ta
                             sk owning the
                     174     ; *                            semaphore is raised to this priority.  It is assumed that yo
                             u will specify
                     175     ; *                            a priority that is LOWER in value than ANY of the tasks comp
                             eting for the
                     176     ; *                            mutex.
                     177     ; *
                     178     ; *              err           is a pointer to an error code which will be returned to your
                              application:
                     179     ; *                               OS_NO_ERR           if the call was successful.

⌨️ 快捷键说明

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