MCPcopy Create free account
hub / github.com/FreeRTOS/FreeRTOS-Kernel / xQueueGiveFromISR

Function xQueueGiveFromISR

queue.c:1154–1319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1152/*-----------------------------------------------------------*/
1153
1154BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
1155 BaseType_t * const pxHigherPriorityTaskWoken )
1156{
1157 BaseType_t xReturn;
1158 UBaseType_t uxSavedInterruptStatus;
1159 Queue_t * const pxQueue = xQueue;
1160
1161 /* Similar to xQueueGenericSendFromISR() but used with semaphores where the
1162 * item size is 0. Don't directly wake a task that was blocked on a queue
1163 * read, instead return a flag to say whether a context switch is required or
1164 * not (i.e. has a task with a higher priority than us been woken by this
1165 * post). */
1166
1167 configASSERT( pxQueue );
1168
1169 /* xQueueGenericSendFromISR() should be used instead of xQueueGiveFromISR()
1170 * if the item size is not 0. */
1171 configASSERT( pxQueue->uxItemSize == 0 );
1172
1173 /* Normally a mutex would not be given from an interrupt, especially if
1174 * there is a mutex holder, as priority inheritance makes no sense for an
1175 * interrupts, only tasks. */
1176 configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->u.xSemaphore.xMutexHolder != NULL ) ) );
1177
1178 /* RTOS ports that support interrupt nesting have the concept of a maximum
1179 * system call (or maximum API call) interrupt priority. Interrupts that are
1180 * above the maximum system call priority are kept permanently enabled, even
1181 * when the RTOS kernel is in a critical section, but cannot make any calls to
1182 * FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h
1183 * then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion
1184 * failure if a FreeRTOS API function is called from an interrupt that has been
1185 * assigned a priority above the configured maximum system call priority.
1186 * Only FreeRTOS functions that end in FromISR can be called from interrupts
1187 * that have been assigned a priority at or (logically) below the maximum
1188 * system call interrupt priority. FreeRTOS maintains a separate interrupt
1189 * safe API to ensure interrupt entry is as fast and as simple as possible.
1190 * More information (albeit Cortex-M specific) is provided on the following
1191 * link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
1192 portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
1193
1194 uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
1195 {
1196 const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting;
1197
1198 /* When the queue is used to implement a semaphore no data is ever
1199 * moved through the queue but it is still valid to see if the queue 'has
1200 * space'. */
1201 if( uxMessagesWaiting < pxQueue->uxLength )
1202 {
1203 const int8_t cTxLock = pxQueue->cTxLock;
1204
1205 traceQUEUE_SEND_FROM_ISR( pxQueue );
1206
1207 /* A task can only have an inherited priority if it is a mutex
1208 * holder - and if there is a mutex holder then the mutex cannot be
1209 * given from an ISR. As this is the ISR version of the function it
1210 * can be assumed there is no mutex holder and no need to determine if
1211 * priority disinheritance is needed. Simply increase the count of

Callers

nothing calls this directly

Calls 2

xTaskRemoveFromEventListFunction · 0.85

Tested by

no test coverage detected