/* Enqueues the caller thread. 
The caller thread is enqueued and put to sleep until it is dequeued or the specified timeouts expires. */
msg_t osalThreadEnqueueTimeoutS(threads_queue_t *tqp, sysinterval_t timeout)
/* Enqueues the caller thread. 
The caller thread is enqueued and put to sleep until it is dequeued or the specified timeouts expires. */
msg_t osalThreadEnqueueTimeoutS(threads_queue_t *tqp, sysinterval_t timeout)
{
    queue_elem_t e;
    msg_t msg;
    osalDbgCheck(tqp != NULL);
    ThreadsQueuePush(tqp, &e);
    msg = osalThreadSuspendTimeoutS(&e.tr, timeout);
    ElementDequeue(&e);
    return msg;
}