this is a backport of https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/188 which is part of FreeRTOS V10.4.2