Skip to content
  1. May 23, 2017
  2. May 22, 2017
  3. May 21, 2017
  4. May 20, 2017
  5. May 19, 2017
  6. May 18, 2017
  7. May 17, 2017
  8. May 16, 2017
    • Gregory Nutt's avatar
      syslog: Add header file inclusion to eliminate a warning; mm/iob: private... · 5ce2ece1
      Gregory Nutt authored
      syslog: Add header file inclusion to eliminate a warning; mm/iob: private function needs static storage class.
      5ce2ece1
    • Gregory Nutt's avatar
      There can be a failure in IOB allocation to some asynchronous behavior caused... · 6a3800f6
      Gregory Nutt authored
      There can be a failure in IOB allocation to some asynchronous behavior caused by the use of sem_post().  Consider this scenario:
      
      Task A holds an IOB.  There are no further IOBs.  The value of semcount is zero.
      Task B calls iob_alloc().  Since there are not IOBs, it calls sem_wait().  The v
      alue of semcount is now -1.
      
      Task A frees the IOB.  iob_free() adds the IOB to the free list and calls sem_post() this makes Task B ready to run and sets semcount to zero NOT 1.  There is one IOB in the free list and semcount is zero.  When Task B wakes up it would increment the sem_count back to the correct value.
      
      But an interrupt or another task runs occurs before Task B executes.  The interrupt or other tak takes the IOB off of the free list and decrements the semcount.  But since semcount is then < 0, this causes the assertion because that is an invalid state in the interrupt handler.
      
      So I think that the root cause is that there the asynchrony between incrementing the semcount.  This change separates the list of IOBs:  Currently there is only a free list of IOBs.  The problem, I believe, is because of asynchronies due sem_post() post cause the semcount and the list content to become out of sync.  This change adds a new 'committed' list:  When there is a task waiting for an IOB, it will go into the committed list rather than the free list before the semaphore is posted.  On the waiting side, when awakened from the semaphore wait, it will expect to find its IOB in the committed list, rather than free list.
      
      In this way, the content of the free list and the value of the semaphore count always remain in sync.
      6a3800f6