Hii. I was using scheuler and wanted to know how this part of code works. The #define CRITICAL_REGION_ENTER() has opening bracket but it is closing after #define CRITICAL_REGION_EXIT(). So, why it is this done this way? And what exaclty happens when we call CRITICAL_REGION_ENTER()?
/**@brief Macro for entering a critical region.
*
* @note Due to implementation details, there must exist one and only one call to
* CRITICAL_REGION_EXIT() for each call to CRITICAL_REGION_ENTER(), and they must be located
* in the same scope.
*/
#ifdef SOFTDEVICE_PRESENT
#define CRITICAL_REGION_ENTER() \
{ \
uint8_t __CR_NESTED = 0; \
app_util_critical_region_enter(&__CR_NESTED);
#else
#define CRITICAL_REGION_ENTER() app_util_critical_region_enter(NULL)
#endif
/**@brief Macro for leaving a critical region.
*
* @note Due to implementation details, there must exist one and only one call to
* CRITICAL_REGION_EXIT() for each call to CRITICAL_REGION_ENTER(), and they must be located
* in the same scope.
*/
#ifdef SOFTDEVICE_PRESENT
#define CRITICAL_REGION_EXIT() \
app_util_critical_region_exit(__CR_NESTED); \
}
#else
#define CRITICAL_REGION_EXIT() app_util_critical_region_exit(0)
#endif