FreeRTOS Learning

I’m learning FreeRTOS currently, I will try to write down what I learned from the source code and share it in this forum. hope it can help the beginner, and if I have made some mistake, it will be highly appreciated if some one can point out.

FreeRTOS Learning

Don’t know how to insert picture, attached picture is how I understood the List of FreeRTOS.

FreeRTOS Learning

Another picture to explain the function: void vListInsert( Listt * const pxList, ListItemt * const pxNewListItem )

FreeRTOS Learning

Picture to explain the function: UBaseTypet uxListRemove( ListItemt * const pxItemToRemove )

FreeRTOS Learning

Hi John, thanks for the clear pictures. That all looks correct to me. As you can see, the List_t type has been implemented with a minimum RAM footprint. All items (elements) know to which list they belong, if any. Each node in the list is part its object. For instance, an example taken from FreeRTOS+TCP: a network buffer is either linked into a free list or into a list of occupied buffers. In order to make it linkable, it gets a ListItem_t field: ~~~~ typedef struct xNETWORKBUFFER { ListItemt xBufferListItem; /* Used to reference the buffer form the free buffer list or a socket. / uint32_t ulIPAddress; / Source or destination IP address, depending on usage scenario. / uint8_t *pucEthernetBuffer; / Pointer to the start of the Ethernet frame. */ … } NetworkBufferDescriptor_t; ~~~~ Now xBufferListItem will always point to one of the two lists. You can add more ListItem_t‘s to your objects to make them linkable to several lists. The List_t type has been exposed in a header file, but normally developers will not make use of them. It is a type definition “internal to the kernel”. But you’re free to use it, of course. Note that with a few additions (wrappers), you can create both FIFO’s and stacks, based on List_t. Other objects are more important for most developers: Queue’s, Semaphores, Event-Groups and the mechanisms to notify (and wake-up) a task.

FreeRTOS Learning

Hello Hein, your explanation help me a lot to move forward, Thank you very much Sir!