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

Function xQueueGenericReset

queue.c:264–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262/*-----------------------------------------------------------*/
263
264BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
265 BaseType_t xNewQueue )
266{
267 Queue_t * const pxQueue = xQueue;
268
269 configASSERT( pxQueue );
270
271 taskENTER_CRITICAL();
272 {
273 pxQueue->u.xQueue.pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */
274 pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U;
275 pxQueue->pcWriteTo = pxQueue->pcHead;
276 pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - 1U ) * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */
277 pxQueue->cRxLock = queueUNLOCKED;
278 pxQueue->cTxLock = queueUNLOCKED;
279
280 if( xNewQueue == pdFALSE )
281 {
282 /* If there are tasks blocked waiting to read from the queue, then
283 * the tasks will remain blocked as after this function exits the queue
284 * will still be empty. If there are tasks blocked waiting to write to
285 * the queue, then one should be unblocked as after this function exits
286 * it will be possible to write to it. */
287 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
288 {
289 if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
290 {
291 queueYIELD_IF_USING_PREEMPTION();
292 }
293 else
294 {
295 mtCOVERAGE_TEST_MARKER();
296 }
297 }
298 else
299 {
300 mtCOVERAGE_TEST_MARKER();
301 }
302 }
303 else
304 {
305 /* Ensure the event queues start in the correct state. */
306 vListInitialise( &( pxQueue->xTasksWaitingToSend ) );
307 vListInitialise( &( pxQueue->xTasksWaitingToReceive ) );
308 }
309 }
310 taskEXIT_CRITICAL();
311
312 /* A value is returned for calling semantic consistency with previous
313 * versions. */
314 return pdPASS;
315}
316/*-----------------------------------------------------------*/
317
318#if ( configSUPPORT_STATIC_ALLOCATION == 1 )

Callers 2

prvInitialiseNewQueueFunction · 0.85
MPU_xQueueGenericResetFunction · 0.85

Calls 2

xTaskRemoveFromEventListFunction · 0.85
vListInitialiseFunction · 0.85

Tested by

no test coverage detected