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

Function xQueueCRSend

queue.c:2438–2510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2436#if ( configUSE_CO_ROUTINES == 1 )
2437
2438 BaseType_t xQueueCRSend( QueueHandle_t xQueue,
2439 const void * pvItemToQueue,
2440 TickType_t xTicksToWait )
2441 {
2442 BaseType_t xReturn;
2443 Queue_t * const pxQueue = xQueue;
2444
2445 /* If the queue is already full we may have to block. A critical section
2446 * is required to prevent an interrupt removing something from the queue
2447 * between the check to see if the queue is full and blocking on the queue. */
2448 portDISABLE_INTERRUPTS();
2449 {
2450 if( prvIsQueueFull( pxQueue ) != pdFALSE )
2451 {
2452 /* The queue is full - do we want to block or just leave without
2453 * posting? */
2454 if( xTicksToWait > ( TickType_t ) 0 )
2455 {
2456 /* As this is called from a coroutine we cannot block directly, but
2457 * return indicating that we need to block. */
2458 vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToSend ) );
2459 portENABLE_INTERRUPTS();
2460 return errQUEUE_BLOCKED;
2461 }
2462 else
2463 {
2464 portENABLE_INTERRUPTS();
2465 return errQUEUE_FULL;
2466 }
2467 }
2468 }
2469 portENABLE_INTERRUPTS();
2470
2471 portDISABLE_INTERRUPTS();
2472 {
2473 if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
2474 {
2475 /* There is room in the queue, copy the data into the queue. */
2476 prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK );
2477 xReturn = pdPASS;
2478
2479 /* Were any co-routines waiting for data to become available? */
2480 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
2481 {
2482 /* In this instance the co-routine could be placed directly
2483 * into the ready list as we are within a critical section.
2484 * Instead the same pending ready list mechanism is used as if
2485 * the event were caused from within an interrupt. */
2486 if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
2487 {
2488 /* The co-routine waiting has a higher priority so record
2489 * that a yield might be appropriate. */
2490 xReturn = errQUEUE_YIELD;
2491 }
2492 else
2493 {
2494 mtCOVERAGE_TEST_MARKER();
2495 }

Callers

nothing calls this directly

Calls 4

prvIsQueueFullFunction · 0.85
prvCopyDataToQueueFunction · 0.85

Tested by

no test coverage detected