Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The buffer manager satisfies the ?rst 10 buffer requests because the semaphore is initialized to 10. When all buffers are used, a task requesting a buffer is suspended until a buffer becomes available. You use µC/OS-III’s OSMemGet() and OSMemPut() (see Chapter 17, “Memory Management” Memory Management) to obtain a buffer from the buffer pool. When a task is finished with the buffer it acquired, the task calls BufRel() to return the buffer to the buffer manager and the buffer is inserted into the linked list before the semaphore is signaled. By encapsulating the interface to the buffer manager in BufReq() and BufRel(), the caller does not need to be concerned with actual implementation details.

...

Note that the details of creating the memory partition are removed since this is discussed in Chapter 17, “Memory Management” Memory Management. The semaphore is used here to extend the memory management capabilities of µC/OS-III, and to provide it with a blocking mechanism. However, only tasks can make BufReq() and BufRel() calls.