FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [January 2014 Threads] xQueueAddToSet/xQueueRemoveFromSet is it safe?Posted by beginend1 on January 24, 2014 Is it safe to use xQueueAddToSet/xQueueRemoveFromSet? The check in those functions are made outside critical section, so there could be race condition. See note in code.
if( ( ( xQUEUE * ) xQueueOrSemaphore )->pxQueueSetContainer != NULL )
{
/* Cannot add a queue/semaphore to more than one queue set. */
xReturn = pdFAIL;
}
/* #### critical setion from here ? #### */
else if( ( ( xQUEUE * ) xQueueOrSemaphore )->uxMessagesWaiting != ( unsigned portBASE_TYPE ) 0 )
{
/* Cannot add a queue/semaphore to a queue set if there are already
items in the queue/semaphore. */
xReturn = pdFAIL;
}
else
{
taskENTER_CRITICAL();
{
( ( xQUEUE * ) xQueueOrSemaphore )->pxQueueSetContainer = xQueueSet;
}
taskEXIT_CRITICAL();
xReturn = pdPASS;
}
return xReturn;
xQueueAddToSet/xQueueRemoveFromSet is it safe?Posted by rtel on January 24, 2014 I'm not sure why the decision was taken not to put a critical section around that line, as there is a critical section in the 'else' statement. No matter what the reason, as this is a very fast function that is generally only called during initialisation anyway, it would seem prudent to move the existing critical section to instead go around the entire if/else if/else statements. It has been done but not checked in yet.
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|