/* Create and start a thread. 
This function starts a new thread. The new thread starts execution by invoking entry(). The argument arg is passed as the sole argument of entry(). */
OS_Status OS_ThreadCreate(OS_Thread_t *thread, const char *name, OS_ThreadEntry_t entry, void *arg, OS_Priority priority, uint32_t stackSize)
/* Create and start a thread. 
This function starts a new thread. The new thread starts execution by invoking entry(). The argument arg is passed as the sole argument of entry(). */
OS_Status OS_ThreadCreate(OS_Thread_t *thread, const char *name, OS_ThreadEntry_t entry, void *arg, OS_Priority priority, uint32_t stackSize)
{
    BaseType_t ret;
    OS_HANDLE_ASSERT(!OS_ThreadIsValid(thread), thread->handle);
    ret = xTaskCreate(entry, name, stackSize / sizeof(StackType_t), arg,
                      priority, &thread->handle);
    if (ret != pdPASS) {
        OS_ERR("err %"OS_BASETYPE_F"\n", ret);
        OS_ThreadSetInvalid(thread);
        return OS_FAIL;
    }
    return OS_OK;
}