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

📄 os_sem.lst

📁 keil的开发环境,把uc/osii操作系统移植到51单片机上,0错误、0警告
💻 LST
📖 第 1 页 / 共 2 页
字号:
 135   2      
 136   2                      TI = 0;
 137   2                      SBUF = 'c';
 138   2                      while(!TI);
 139   2          }
 140   1          if (pevent->OSEventCnt > 0)  /* If sem. is positive, resource available ...   */
 141   1          {                    
 142   2              pevent->OSEventCnt--;                         /* ... decrement semaphore only if positive.     */
 143   2              OS_EXIT_CRITICAL();
 144   2              *err = OS_NO_ERR;
 145   2          } 
 146   1          else if (OSIntNesting > 0)  /* See if called from ISR ...                    */
 147   1          {                   
 148   2              OS_EXIT_CRITICAL();                           /* ... can't PEND from an ISR                    */
 149   2              *err = OS_ERR_PEND_ISR;
 150   2          } 
 151   1          else 
 152   1          {                                          /* Otherwise, must wait until event occurs       */
 153   2              OSTCBCur->OSTCBStat    |= OS_STAT_SEM;        /* Resource not available, pend on semaphore     */
 154   2              OSTCBCur->OSTCBDly      = timeout;            /* Store pend timeout in TCB                     */
 155   2              OSEventTaskWait(pevent);                      /* Suspend task until event or timeout occurs    */
 156   2              OS_EXIT_CRITICAL();
 157   2              OSSched();                                    /* Find next highest priority task ready         */
 158   2              OS_ENTER_CRITICAL();
 159   2              if (OSTCBCur->OSTCBStat & OS_STAT_SEM) 
 160   2              {      /* Must have timed out if still waiting for event*/
 161   3                  OSEventTO(pevent);
 162   3                  OS_EXIT_CRITICAL();
 163   3                  *err = OS_TIMEOUT;                        /* Indicate that didn't get event within TO      */
 164   3              } 
 165   2              else 
 166   2              {
 167   3                  OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;
 168   3                  OS_EXIT_CRITICAL();
 169   3                  *err = OS_NO_ERR;
 170   3              }
 171   2          }
 172   1      }
 173          #endif
 174          /*$PAGE*/
 175          /*
 176          *********************************************************************************************************
 177          *                                         POST TO A SEMAPHORE
 178          *
 179          * Description: This function signals a semaphore
C51 COMPILER V7.10   OS_SEM                                                                05/10/2005 00:01:51 PAGE 4   

 180          *
 181          * Arguments  : pevent        is a pointer to the event control block associated with the desired 
 182          *                            semaphore.
 183          *
 184          * Returns    : OS_NO_ERR          The call was successful and the semaphore was signaled.
 185          *              OS_SEM_OVF         If the semaphore count exceeded its limit.  In other words, you have 
 186          *                                 signalled the semaphore more often than you waited on it with either
 187          *                                 OSSemAccept() or OSSemPend().
 188          *              OS_ERR_EVENT_TYPE  If you didn't pass a pointer to a semaphore
 189          *********************************************************************************************************
 190          */
 191          #if OS_Sem_Post_EN
 192          INT8U OSSemPost (OS_EVENT *pevent)reentrant
 193          {
 194   1          OS_ENTER_CRITICAL();
 195   1          if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
 196   2              OS_EXIT_CRITICAL();
 197   2                      TI = 0;
 198   2                      SBUF = 'd';
 199   2                      while(!TI);
 200   2              return (OS_ERR_EVENT_TYPE);
 201   2          }
 202   1          if (pevent->OSEventGrp) {                              /* See if any task waiting for semaphore    */
 203   2              OSEventTaskRdy(pevent, (void *)0, OS_STAT_SEM);    /* Ready highest prio task waiting on event */
 204   2              OS_EXIT_CRITICAL();
 205   2              OSSched();                                    /* Find highest priority task ready to run       */
 206   2              return (OS_NO_ERR);
 207   2          } else {
 208   2              if (pevent->OSEventCnt < 65535) {             /* Make sure semaphore will not overflow         */
 209   3                  pevent->OSEventCnt++;                     /* Increment semaphore count to register event   */
 210   3                  OS_EXIT_CRITICAL();
 211   3                  return (OS_NO_ERR);
 212   3              } else {                                      /* Semaphore value has reached its maximum       */
 213   3                  OS_EXIT_CRITICAL();
 214   3                  return (OS_SEM_OVF);
 215   3              }
 216   2          }
 217   1      }
 218          #endif
 219          /*
 220          *********************************************************************************************************
 221          *                                          QUERY A SEMAPHORE
 222          *
 223          * Description: This function obtains information about a semaphore
 224          *
 225          * Arguments  : pevent        is a pointer to the event control block associated with the desired 
 226          *                            semaphore
 227          *
 228          *              dataptr         is a pointer to a structure that will contain information about the 
 229          *                            semaphore.
 230          *
 231          * Returns    : OS_NO_ERR          The call was successful and the message was sent
 232          *              OS_ERR_EVENT_TYPE  If you are attempting to obtain data from a non semaphore.
 233          *********************************************************************************************************
 234          */
 235          #if   OS_Sem_Query_EN
              INT8U OSSemQuery (OS_EVENT *pevent, OS_SEM_DATA *dataptr)reentrant
              {
                  INT8U  i;
                  INT8U *psrc;
                  INT8U *pdest;
                  
C51 COMPILER V7.10   OS_SEM                                                                05/10/2005 00:01:51 PAGE 5   

                  
                  OS_ENTER_CRITICAL();
                  if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
                      OS_EXIT_CRITICAL();
                      return (OS_ERR_EVENT_TYPE);
                  }
                  dataptr->OSEventGrp = pevent->OSEventGrp;                /* Copy message mailbox wait list           *
             -/
                  psrc              = &pevent->OSEventTbl[0];
                  pdest             = &dataptr->OSEventTbl[0];
                  for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
                      *pdest++ = *psrc++;   
                  }
                  dataptr->OSCnt      = pevent->OSEventCnt;                /* Get semaphore count                      *
             -/
                  OS_EXIT_CRITICAL();
                  return (OS_NO_ERR);
              }
              #endif
 259          #endif


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    575    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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