This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TSK_sleep()

I want to create a thread that loops and waits for events via a QUE object.  However, I note that the QUE_get(), and QUE_empty() don't block.  So I tryed using a TSK_sleep() function in my task.  I have a priority 4 task that is basically a while() loop reading from the Queue and then going to sleep.  I set the TSK_sleep(1), or the nticks = 1 and the task never goes to sleep.  If I comment TSK_sleep(1); out, my task executes and does not let lower priority stuff execute.  What have I not configure so that the TSK_sleep() function with nticks = 1 never wakes up?

 

Robert

  • Robert Bradshaw said:
    I want to create a thread that loops and waits for events via a QUE object.  However, I note that the QUE_get(), and QUE_empty() don't block.  So I tryed using a TSK_sleep() function in my task.

    Correct -- QUE is just a simple building block for creating doubly linked lists.  You should use a semaphore to block.  FYI, the MBOX (mailbox) module is essentially a QUE and a semaphore -- why not just use MBOX?

    Robert Bradshaw said:
    I set the TSK_sleep(1), or the nticks = 1 and the task never goes to sleep.

    How do you know the task never goes to sleep?

    Robert Bradshaw said:
    If I comment TSK_sleep(1); out, my task executes and does not let lower priority stuff execute.

    DSP/BIOS is a pre-emptive scheduler.  The highest priority "ready" thread always runs.  If your higher priority thread never goes to a suspend/blocked state then lower priority threads do not execute.  This is by design.

    Robert Bradshaw said:
    What have I not configure so that the TSK_sleep() function with nticks = 1 never wakes up?

    Huh?  Too many negatives.  From your above statement it sounds like things are working as expected.  I suggest simply switching to mailboxes.