}\r
/*-----------------------------------------------------------*/\r
\r
-xEventBitsType xEventGroupSync( xEventGroupHandle xEventGroup, xEventBitsType uxBitsToSet, xEventBitsType uxBitsToWaitFor, portTickType xBlockTime )\r
+xEventBitsType xEventGroupSync( xEventGroupHandle xEventGroup, xEventBitsType uxBitsToSet, xEventBitsType uxBitsToWaitFor, portTickType xTicksToWait )\r
{\r
xEventBitsType uxOriginalBitValue, uxReturn;\r
xEVENT_BITS *pxEventBits = ( xEVENT_BITS * ) xEventGroup;\r
portBASE_TYPE xYieldedAlready;\r
\r
+ #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r
+ {\r
+ configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );\r
+ }\r
+ #endif\r
+\r
vTaskSuspendAll();\r
{\r
uxOriginalBitValue = pxEventBits->uxEventBits;\r
already unless this is the only task in the rendezvous. */\r
pxEventBits->uxEventBits &= uxBitsToWaitFor;\r
\r
- xBlockTime = 0;\r
+ xTicksToWait = 0;\r
}\r
else\r
{\r
- if( xBlockTime != ( portTickType ) 0 )\r
+ if( xTicksToWait != ( portTickType ) 0 )\r
{\r
/* Store the bits that the calling task is waiting for in the\r
task's event list item so the kernel knows when a match is\r
found. Then enter the blocked state. */\r
- vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | taskCLEAR_EVENTS_ON_EXIT_BIT | taskWAIT_FOR_ALL_BITS ), xBlockTime );\r
+ vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | taskCLEAR_EVENTS_ON_EXIT_BIT | taskWAIT_FOR_ALL_BITS ), xTicksToWait );\r
}\r
else\r
{\r
}\r
xYieldedAlready = xTaskResumeAll();\r
\r
- if( xBlockTime != ( portTickType ) 0 )\r
+ if( xTicksToWait != ( portTickType ) 0 )\r
{\r
if( xYieldedAlready == pdFALSE )\r
{\r
}\r
/*-----------------------------------------------------------*/\r
\r
-xEventBitsType xEventGroupWaitBits( xEventGroupHandle xEventGroup, xEventBitsType uxBitsToWaitFor, portBASE_TYPE xClearOnExit, portBASE_TYPE xWaitForAllBits, portTickType xBlockTime )\r
+xEventBitsType xEventGroupWaitBits( xEventGroupHandle xEventGroup, xEventBitsType uxBitsToWaitFor, portBASE_TYPE xClearOnExit, portBASE_TYPE xWaitForAllBits, portTickType xTicksToWait )\r
{\r
xEVENT_BITS *pxEventBits = ( xEVENT_BITS * ) xEventGroup;\r
const xEventBitsType uxCurrentEventBits = pxEventBits->uxEventBits;\r
itself, and that at least one bit is being requested. */\r
configASSERT( ( uxBitsToWaitFor & taskEVENT_BITS_CONTROL_BYTES ) == 0 );\r
configASSERT( uxBitsToWaitFor != 0 );\r
+ #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r
+ {\r
+ configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );\r
+ }\r
+ #endif\r
\r
taskENTER_CRITICAL();\r
{\r
if( ( uxCurrentEventBits & uxBitsToWaitFor ) != ( xEventBitsType ) 0 )\r
{\r
/* At least one of the bits was set. No need to block. */\r
- xBlockTime = 0;\r
+ xTicksToWait = 0;\r
}\r
}\r
else\r
if( ( uxCurrentEventBits & uxBitsToWaitFor ) == uxBitsToWaitFor )\r
{\r
/* All the bits were set, no need to block. */\r
- xBlockTime = 0;\r
+ xTicksToWait = 0;\r
}\r
}\r
\r
/* The task can return now if either its wait condition is already met\r
or the requested block time is 0. */\r
- if( xBlockTime == ( portTickType ) 0 )\r
+ if( xTicksToWait == ( portTickType ) 0 )\r
{\r
/* No need to block, just set the return value. */\r
uxReturn = uxCurrentEventBits;\r
/* Store the bits that the calling task is waiting for in the\r
task's event list item so the kernel knows when a match is\r
found. Then enter the blocked state. */\r
- vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | uxControlBits ), xBlockTime );\r
+ vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | uxControlBits ), xTicksToWait );\r
portYIELD_WITHIN_API();\r
}\r
}\r
taskEXIT_CRITICAL();\r
\r
- if( xBlockTime != ( portTickType ) 0 )\r
+ if( xTicksToWait != ( portTickType ) 0 )\r
{\r
/* The task blocked to wait for its required bits to be set - at this\r
point either the required bits were set or the block time expired. If\r
\r
pxList = &( pxEventBits->xTasksWaitingForBits );\r
pxListEnd = listGET_END_MARKER( pxList ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */\r
- pxListItem = listGET_HEAD_ENTRY( pxList );\r
vTaskSuspendAll();\r
{\r
+ pxListItem = listGET_HEAD_ENTRY( pxList );\r
+\r
/* Set the bits. */\r
pxEventBits->uxEventBits |= uxBitsToSet;\r
\r
xEventBitsType uxBitsToWaitFor,\r
portBASE_TYPE xClearOnExit,\r
portBASE_TYPE xWaitForAllBits,\r
- portTickType xBlockTime );\r
+ portTickType xTicksToWait );\r
</pre>\r
*\r
* [Potentially] block to wait for one or more bits to be set within a\r
* pdFALSE then xEventGroupWaitBits() will return when any one of the bits set\r
* in uxBitsToWaitFor is set or the specified block time expires.\r
*\r
- * @param xBlockTime The maximum amount of time (specified in 'ticks') to wait\r
+ * @param xTicksToWait The maximum amount of time (specified in 'ticks') to wait\r
* for one/all (depending on the xWaitForAllBits value) of the bits specified by\r
* uxBitsToWaitFor to become set.\r
*\r
void aFunction( xEventGroupHandle xEventGroup )\r
{\r
xEventBitsType uxBits;\r
- const portTickType xBlockTime = 100 / portTICK_RATE_MS;\r
+ const portTickType xTicksToWait = 100 / portTICK_RATE_MS;\r
\r
// Wait a maximum of 100ms for either bit 0 or bit 4 to be set within\r
// the event group. Clear the bits before exiting.\r
BIT_0 | BIT_4, // The bits within the event group to wait for.\r
pdTRUE, // BIT_0 and BIT_4 should be cleared before returning.\r
pdFALSE, // Don't wait for both bits, either bit will do.\r
- xBlockTime ); // Wait a maximum of 100ms for either bit to be set.\r
+ xTicksToWait ); // Wait a maximum of 100ms for either bit to be set.\r
\r
if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )\r
{\r
}\r
else\r
{\r
- // xEventGroupWaitBits() returned because xBlockTime ticks passed\r
+ // xEventGroupWaitBits() returned because xTicksToWait ticks passed\r
// without either BIT_0 or BIT_4 becoming set.\r
}\r
}\r
* \defgroup xEventGroupWaitBits xEventGroupWaitBits\r
* \ingroup EventGroup\r
*/\r
-xEventBitsType xEventGroupWaitBits( xEventGroupHandle xEventGroup, xEventBitsType uxBitsToWaitFor, portBASE_TYPE xClearOnExit, portBASE_TYPE xWaitForAllBits, portTickType xBlockTime ) PRIVILEGED_FUNCTION;\r
+xEventBitsType xEventGroupWaitBits( xEventGroupHandle xEventGroup, xEventBitsType uxBitsToWaitFor, portBASE_TYPE xClearOnExit, portBASE_TYPE xWaitForAllBits, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;\r
\r
/**\r
* event_groups.h\r
xEventBitsType xEventGroupSync( xEventGroupHandle xEventGroup,\r
xEventBitsType uxBitsToSet,\r
xEventBitsType uxBitsToWaitFor,\r
- portTickType xBlockTime );\r
+ portTickType xTicksToWait );\r
</pre>\r
*\r
* Atomically set bits within an event group, then wait for a combination of\r
* uxBitsToWaitFor to 0x05. To wait for bits 0 and bit 1 and bit 2 set\r
* uxBitsToWaitFor to 0x07. Etc.\r
*\r
- * @param xBlockTime The maximum amount of time (specified in 'ticks') to wait\r
+ * @param xTicksToWait The maximum amount of time (specified in 'ticks') to wait\r
* for all of the bits specified by uxBitsToWaitFor to become set.\r
*\r
* @return The value of the event group at the time either the bits being waited\r
void vTask0( void *pvParameters )\r
{\r
xEventBitsType uxReturn;\r
- portTickType xBlockTime = 100 / portTICK_RATE_MS;\r
+ portTickType xTicksToWait = 100 / portTICK_RATE_MS;\r
\r
for( ;; )\r
{\r
// by ALL_SYNC_BITS. All three tasks have reached the synchronisation\r
// point when all the ALL_SYNC_BITS are set. Wait a maximum of 100ms\r
// for this to happen.\r
- uxReturn = xEventGroupSync( xEventBits, TASK_0_BIT, ALL_SYNC_BITS, xBlockTime );\r
+ uxReturn = xEventGroupSync( xEventBits, TASK_0_BIT, ALL_SYNC_BITS, xTicksToWait );\r
\r
if( ( uxReturn & ALL_SYNC_BITS ) == ALL_SYNC_BITS )\r
{\r
* \defgroup xEventGroupSync xEventGroupSync\r
* \ingroup EventGroup\r
*/\r
-xEventBitsType xEventGroupSync( xEventGroupHandle xEventGroup, xEventBitsType uxBitsToSet, xEventBitsType uxBitsToWaitFor, portTickType xBlockTime ) PRIVILEGED_FUNCTION;\r
+xEventBitsType xEventGroupSync( xEventGroupHandle xEventGroup, xEventBitsType uxBitsToSet, xEventBitsType uxBitsToWaitFor, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;\r
\r
\r
/**\r
*/\r
#define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS()\r
\r
-/* Definitions returned by xTaskGetSchedulerState(). */\r
-#define taskSCHEDULER_NOT_STARTED ( ( portBASE_TYPE ) 0 )\r
-#define taskSCHEDULER_RUNNING ( ( portBASE_TYPE ) 1 )\r
-#define taskSCHEDULER_SUSPENDED ( ( portBASE_TYPE ) 2 )\r
+/* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is\r
+0 to generate more optimal code when configASSERT() is defined as the constant\r
+is used in assert() statements. */\r
+#define taskSCHEDULER_SUSPENDED ( ( portBASE_TYPE ) 0 )\r
+#define taskSCHEDULER_NOT_STARTED ( ( portBASE_TYPE ) 1 )\r
+#define taskSCHEDULER_RUNNING ( ( portBASE_TYPE ) 2 )\r
+\r
\r
/*-----------------------------------------------------------\r
* TASK CREATION API\r
* there be no higher priority tasks waiting on the same event) or\r
* the delay period expires.\r
*\r
- * The 'unordered' version replaces the event list item value with the \r
+ * The 'unordered' version replaces the event list item value with the\r
* xItemValue value, and inserts the list item at the end of the list.\r
*\r
* The 'ordered' version uses the existing event list item value (which is the\r
* Removes a task from both the specified event list and the list of blocked\r
* tasks, and places it on a ready queue.\r
*\r
- * xTaskRemoveFromEventList()/xTaskRemoveFromUnorderedEventList() will be called \r
- * if either an event occurs to unblock a task, or the block timeout period \r
+ * xTaskRemoveFromEventList()/xTaskRemoveFromUnorderedEventList() will be called\r
+ * if either an event occurs to unblock a task, or the block timeout period\r
* expires.\r
*\r
* xTaskRemoveFromEventList() is used when the event list is in task priority\r
configASSERT( pxQueue );\r
configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) );\r
+ #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r
+ {\r
+ configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );\r
+ }\r
+ #endif\r
+\r
\r
/* This function relaxes the coding standard somewhat to allow return\r
statements within the function itself. This is done in the interest\r
\r
configASSERT( pxQueue );\r
configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
-\r
+ #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r
+ {\r
+ configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );\r
+ }\r
+ #endif\r
+ \r
/* This function relaxes the coding standard somewhat to allow return\r
statements within the function itself. This is done in the interest\r
of execution time efficiency. */\r
{\r
if( pxTCB == pxCurrentTCB )\r
{\r
+ configASSERT( uxSchedulerSuspended == 0 );\r
portYIELD_WITHIN_API();\r
}\r
}\r
\r
configASSERT( pxPreviousWakeTime );\r
configASSERT( ( xTimeIncrement > 0U ) );\r
+ configASSERT( uxSchedulerSuspended == 0 );\r
\r
vTaskSuspendAll();\r
{\r
portTickType xTimeToWake;\r
signed portBASE_TYPE xAlreadyYielded = pdFALSE;\r
\r
+\r
/* A delay time of zero just forces a reschedule. */\r
if( xTicksToDelay > ( portTickType ) 0U )\r
{\r
+ configASSERT( uxSchedulerSuspended == 0 );\r
vTaskSuspendAll();\r
{\r
traceTASK_DELAY();\r
if( xSchedulerRunning != pdFALSE )\r
{\r
/* The current task has just been suspended. */\r
+ configASSERT( uxSchedulerSuspended == 0 );\r
portYIELD_WITHIN_API();\r
}\r
else\r