Before using FreeRTOS I used a simple ring buffer to hold a trace of information, arranged so that if it filled new items would overwrite the oldest, so I always had the newest information if they were written before they can be read. What is the easiest way of implementing this in FreeRTOS, by checking if the queue is ful and then eleting the oldest item before inserting a new one? Or I could just use a semaphore with my existing ring buffer code.
For tracing, I would keep on using the ring buffer because it is 'lite'.
Here's another example:
which can easily be used during an ISR.
For 'real-time' tracing, I would prefer to occasionally lose a message rather than protect every trace action with a semaphore.
But if you want to use queues, that is possible of course.
Note that a queue could either store characters (which is 'expensive') or pointers to messages.
And also the caller will have to make sure that there is space by removing an old message if it is full... and action which could also be protected by a semaphore...
Thanks for the answer, the post you pointed to provided the answers. I shall use my lightweight ringbuffer implementation, with protection whilst I modify the buffer pointers with a critical section, that will disable interrupts for a few cycles only. FreeRTOS queues are far too heavy a solution for just logging a few events. I don't need to log in interrupts, only in tasks, but the critical sections will prevent a task switch in the middle of modifying the ring buffer pointers.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.