How can i use the same delay before and after starting a thread

This may be a very stupid question but i am very new to RTOS and i haven’t been able to find where this is addressed. i have a function that i would like to be able to call either in the initialization before any threads are actually running or from a running thread (i.e., in the init section of main before the ostask scheduler starts as well as in a thread after the scheduler is running). HAL_Delay won’t work properly after the thread starts and osDelay doesn’t seem to work before the thread and scheduler starts. is there a way to have a delay in a function so that function can be used regardless of where it is used? for the moment i am just playing with the keil examples,e.g., FreeRTOS thread creation and moving delays around and trying different delays on an eval board. so i am stuck right out of the gates! thanks

How can i use the same delay before and after starting a thread

Neither HAL_Delay or osDelay are FreeRTOS functions and I have no idea what they do, so I cannot comment on them. After the scheduler has started you can use vTaskDelay() or vTaskDelayUntil() – but they cannot be used before the scheduler starts. You do do something like this:
if( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED )
{
    MyDelayFunction(); /* whatever that is */
}
else
{
    vTaskDelay();
}

How can i use the same delay before and after starting a thread

Thank you, this confirms my understanding (as limited as that may be at this point). The HAL_Delay is part of the hardware abstraction layer for our processor (STM32 à la Keil) and the osDelay is part of the CMSIS library and probably others. This is off-topic, but at this point we are trying to make somewhat of an informed decision between Keil RTX and OpenRTOS so if there is any sort of comparison documentation that exists it would be appreciated

How can i use the same delay before and after starting a thread

if there is any sort of comparison documentation that exists it would be appreciated
They are both small OS’s solving the same problem. A lot more people use FreeRTOS, probably because its API is easier to use and you can use it with any compiler.