Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Updated Jun 2025

xQueueSendToFrontFromISR

[Queue Management]

queue.h

1 BaseType_t xQueueSendToFrontFromISR
2 (
3 QueueHandle_t xQueue,
4 const void *pvItemToQueue,
5 BaseType_t *pxHigherPriorityTaskWoken
6 );

This is a macro that calls xQueueGenericSendFromISR().

Post an item to the front of a queue. It is safe to use this function from within an interrupt service routine.

Items are queued by copy not reference so it is preferable to either only send small items, or alternatively send a pointer to the item.

Parameters:

  • xQueue

    The handle to the queue on which the item is to be posted.

  • pvItemToQueue

    A pointer to the item that is to be placed on the queue. The size of the items the queue will hold was defined when the queue was created, so this many bytes will be copied from pvItemToQueue into the queue storage area.

  • pxHigherPriorityTaskWoken

    xQueueSendToFrontFromISR() will set *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task to unblock, and the unblocked task has a priority higher than the currently running task. If xQueueSendToFrontFromISR() sets this value to pdTRUE then a context switch should be requested before the interrupt is exited.From FreeRTOS V7.3.0 pxHigherPriorityTaskWoken is an optional parameter and can be set to NULL.

Returns:

pdPass if data was successfully sent to the queue, otherwise errQUEUE_FULL.

Example usage:

1void vBufferISR( void )
2{
3char cIn;
4BaseType_t xHigherPriorityTaskWoken;
5
6 /* We have not woken a task at the start of the ISR. */
7 xHigherPriorityTaskWoken = pdFALSE;
8
9 /* Obtain a byte from the buffer. */
10 cIn = portINPUT\_BYTE( RX\_REGISTER\_ADDRESS );
11
12 if( cIn == EMERGENCY\_MESSAGE )
13 {
14 /* Post the byte to the front of the queue. */
15 xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
16 }
17 else
18 {
19 /* Post the byte to the back of the queue. */
20 xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
21 }
22
23 /* Did sending to the queue unblock a higher priority task? */
24 if( xHigherPriorityTaskWoken )
25 {
26 /* Actual macro used here is port specific. */
27 taskYIELD\_FROM\_ISR ();
28 }
29}