 Now let's discuss very interesting communication mechanism within 3R Toys, direct to task notification. Direct to task notification is available within 3R Toys from its version 8.2.0. Within CMC's IS it is covered within version 1.0 as signals and in version 2 as thread flags. To use this mechanism within 3R Toys it is necessary to enable config use task notifications within 3R Toys config.h file. It will add to each task control block 2 fields, 32-bit notification value and 8-bit notification state. Within the notification value most significant bit is reserved, so we have 31 bits to be used. As the notification data are stored within tcb of each task it is not needed to create a separate operating system object. Thus using this method is 35% faster and uses less RAM than unblocking a task with a binary semaphore for example. We should be aware of some limitations of this method as well. It can be used to notify only one task at the time, like in the name direct to task notification. Using this mechanism once the task is waiting for some signals it will be within blocked state, but ascending task cannot wait in a blocked state for send complete. It is just set the flag and continue execution. To use thread flags within CMC's OS V2 we need to enable config use task notifications in 3R Toys config.h file. Thread flags are used to send small portion of data up to 24 bits between tasks or threads or from IRQ to task. Single thread flag is defined as a bit. The maximum number of thread flags is defined within CMC's underscore OS.h file as OS feature underscore signals and is equal to 24. It is not possible to configure it from stm32cubemix nor stm32cubede. There is no function to create thread flags components as those are components within task control block of each task. This is why once we start using task notification we should take into account an extension of all TCB, so task control blocks, of the tasks in the system. To set specified flags within selected task thread we need to use OS thread flags set function. It needs two arguments. A handler to the task where we would like to set the flags and the flags mask we would like to set there. In fact those values are sent via this function will be ORed so there would be the OR function done between the mask we would like to have and existing one which is present of an selected task control block. This function returns flags after the setting operation. Please notice that we cannot clear the flags using OS thread flag set function. There is a dedicated function called OS thread flags clear which is using this function is accepting only one argument. It is the mask of flags which needs to be cleared within the task control block of the task from where we are calling this function. We can wait for specific mask of the flags using function OS thread flags wait. This function needs three arguments. The first one is a mask of the flags we are waiting for then options and the third one the maximum delay the task will wait. So it will be in blocked state waiting for a specific mask of the flags. This function is always called by the task checking its own thread flags filled with an own task control block. So this function mustn't be called from the interrupt procedure. Let's spend a while on the second argument options. It is coded on two bits and can be a combination of below values. If it's zero so OS flag wait any it would wait for any of the flags specified in wait function. So any set bit unlocks the function. So we will not wait for all of the bits from the mask but any of them can unblock our task. Then OS flag wait all which is codified as one. Once this option is set the function will wait for all of the flags specified in wait condition. Then if there is option OS flags no clear which is coded as two. There would be no clear operation of the flags after a successful execution of the function. So it can be reused later on and the flags would be kept on the state which is after this function execution. We can combine options together so for example OS flags no clear can be combined with OS flags wait any or with OS flags wait all. We can select more than one options using the OR operation. Let's have a closer look at direct to task notification API functions. Within CMC's OS version one it has been called signals. Within CMC's OS version two which we are using at this session it has been renamed to thread flags as it is similar structure to event flags. Within original 3R2S API this mechanism is called task notification. Complete 3R2S API for this is stored within task.hfire. To use it we need to define config use task notifications within 3R2S config.hfire. Thank you for watching this video.