BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
Each RTOS task has a 32-bit notification value which is initialised to
zero when the RTOS task is created. An RTOS task notification is an event sent
directly to a task that can unblock the receiving task, and
optionally update the receiving task's notification value.
If a task is in the Blocked state to wait for a notification when the notification
arrives then the task immediately exits the Blocked state and the notification
does not remain pending. If a task was not waiting for a notification when a
notification arrives then the notification will remain pending until the
receiving task reads its notification value.
xTaskNotifyStateClear() is used to clear (Pending to Not Pending)
a pending notification without the receiving task first needing to read its
xTaskNotifyStateClear() does not change the notification value.
The handle of the RTOS task that will have its notification
state cleared. Set xTask to NULL to clear the notification
state of the calling task.
To obtain a task's handle create the task using
xTaskCreate() and make use of the
pxCreatedTask parameter, or create the task using
and store the returned value, or use the task's name in a
call to xTaskGetHandle().
The handle of the currently executing RTOS task is returned by
If the task referenced by xTask had a notification pending, and the notification
was cleared, then pdTRUE is returned. If the task referenced by xTask didn't
have a notification pending then pdFALSE is returned.
[More examples are referenced from the main RTOS task notifications page]
/* An example UART send function. The function starts a UART transmission then
waits to be notified that the transmission is complete. The transmission
complete notification is sent from the UART interrupt. The calling task's
notification state is cleared before the transmission is started to ensure it is
not co-incidentally already pending before the task attempts to block on its
notification state. */
void vSerialPutString( const signed char * const pcStringToSend,
unsigned short usStringLength )
const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 5000 );
/* xSendingTask holds the handle of the task waiting for the transmission to
complete. If xSendingTask is NULL then a transmission is not in progress.
Don't start to send a new string unless transmission of the previous string
is complete. */
if( ( xSendingTask == NULL ) && ( usStringLength > 0 ) )
/* Ensure the calling task's notification state is not already
xTaskNotifyStateClear( NULL );
/* Store the handle of the transmitting task. This is used to unblock
the task when the transmission has completed. */
xSendingTask = xTaskGetCurrentTaskHandle();
/* Start sending the string - the transmission is then controlled by an
UARTSendString( pcStringToSend, usStringLength );
/* Wait in the Blocked state (so not using any CPU time) until the UART
ISR sends a notification to xSendingTask to notify (and unblock) the
task when the transmission is complete. */
ulTaskNotifyTake( pdTRUE, xMaxBlockTime );
Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd..
See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.