Does xQueueSendToBack() work inside a non-ISR or non-tasks too?

shubham294 wrote on Monday, September 04, 2017:

Hi folks,

I was wondering if it is possible to enque an item to a queue by an entity other than a FreeRTOS task/ISR.

I was going through the multi-threaded netconn API implementation in LWIP and saw that there was a function which polls the ethernet drivers and enques an item (actually, posts in a mailbox) to a FreeRTOS queue. That function seems to be neither a FreeRTOS task, nor an ISR. As far as I know, the scheduler needs to know the call context, which often is a task so that the calling task can be put into blocked/un-blocked state.

I could be wrong at some places so please feel free to correct me.

heinbali01 wrote on Monday, September 04, 2017:

That function was neither a FreeRTOS task and nor an ISR

Once the scheduler has started, all running code is either called from a task, or from an ISR.

As you probably know, ISR code uses FreeRTOS API’s that end with FromISR(). All other API’s are being used in a task context. And yes there are a few exceptions, depending on the type of port.

So xQueueSendToBack() can be called from within a task.

I’m afraid that I don’t know how all details of lwIP ported to FreeRTOS.

FreeRTOS has developed its own complete TCP/IP stack called FreeRTOS+TCP. After a few years of development and intensive testing, we now consider it stable. It is very much integrated with the kernel. It uses kernel primitives to implement API’s and message passing. It has been ported to several hardware platforms ( CPU’s and PHY’s ).