/* Blocks the thread while waiting for the semaphore to be signaled. If the "timeout" argument is non-zero, the thread should only be blocked for the specified time (measured in milliseconds).  */
int osi_sem_take(osi_sem_t *sem, uint32_t timeout)
/* Blocks the thread while waiting for the semaphore to be signaled. If the "timeout" argument is non-zero, the thread should only be blocked for the specified time (measured in milliseconds).  */
int osi_sem_take(osi_sem_t *sem, uint32_t timeout)
{
    int ret = 0;
    if (timeout ==  OSI_SEM_MAX_TIMEOUT) {
        if (xSemaphoreTake(*sem, portMAX_DELAY) != pdTRUE) {
            ret = -1;
        }
    } else {
        if (xSemaphoreTake(*sem, timeout / portTICK_PERIOD_MS) != pdTRUE) {
            ret = -2;
        }
    }
    return ret;
}