vinifr

sys_mbox_free

Mar 26th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.87 KB | None | 0 0
  1. /**
  2.  * Destroys a mailbox.
  3.  *
  4.  * @param mbox is the mailbox to be destroyed.
  5.  */
  6. void
  7. sys_mbox_free(sys_mbox_t *mbox)
  8. {
  9.     u32_t i;
  10.   /* There should not be any messages waiting (if there are it is a bug).  If
  11.      any are waiting, increment the mailbox error count. */
  12. #if RTOS_FREERTOS
  13.   if(uxQueueMessagesWaiting(mbox->queue) != 0) {
  14. #endif /* RTOS_FREERTOS */
  15.  
  16. #if SYS_STATS
  17.     STATS_INC(sys.mbox.err);
  18. #endif /* SYS_STATS */
  19.   }
  20.  
  21.     /* Find a mailbox that is in use. */
  22.     for(i = 0; i < SYS_MBOX_MAX; i++) {
  23.       if(mboxes[i].queue == mbox->queue) {
  24.         break;
  25.       }
  26.     }
  27.  
  28.   /* Delete Sem , By Jin */
  29.     vQueueDelete(mbox->queue);
  30.   /* Clear the queue handle. */
  31.   mbox->queue = 0;
  32.   /* Clear the queue handle in global array. */
  33.   mboxes[i].queue = 0;
  34.  
  35.   /* Update the mailbox statistics. */
  36. #if SYS_STATS
  37.    STATS_DEC(sys.mbox.used);
  38. #endif /* SYS_STATS */
  39. }
Add Comment
Please, Sign In to add comment