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.

task interval in RTOS

I evaluate the ICE with RTOS and the Beckhoff EtherCAT stack.

There is a 'task1' which eventually calls my own Handle_TwinCAT function. I toggle a pin on the ICE to see the interval between two calls to may funktion. This interval is approx. 30ms. This is far to slow. How can tell the scheduler to start my task say every 200us?

Michael

  • The TI-RTOS kernel is a preemptive RTOS. The highest priority thread (Hwi, Swi, or Task) runs. What other threads do you have in the system? Are they higher priority and potentially running for a long time (and thus delaying other tasks). What is "task1" blocked on? Generally a task has the following structure

    Void myTask(UArg arg0, UArg arg1)

    {

        // setup code

        while (1) {

            // Block on a semaphore waiting for some action to post the semaphore and let the task run

            // or Task_sleep for some duration.

            // perform necessary actions

        }

  • The software is the EtherCAT example application.

    There are two tasks with priority 6, two tasks with priority 8, one with priority 4 and my own task with priority 15.

    From your RTOS description it sounds like it is not a really preemptive real time OS but a cooperative OS. In my understanding in a preemptive OS a task is stopped after consuming it's time slot and the next ready task is started. Here it seems that a task which loops forever such as while(1); can block the other tasks. Is this really true?

  • The TI-RTOS scheduler is not a time-sliced/round-robin. The highest priority thread that is ready to run will run until it completes (e.g. ISR ends or, for Tasks, hits a blocking call like Task_sleep or blocks on a semaphore).

    From Wikipedia (en.wikipedia.org/.../Real-time_operating_system)

    The most common designs are:

    • Event-driven which switches tasks only when an event of higher priority needs servicing, called preemptive priority, or priority scheduling.
    • Time-sharing designs switch tasks on a regular clocked interrupt, and on events, called round robin.

    Yes, if you do while(1); in the highest priority task, no other tasks will ever run (Hwi and Swi threads will because they have higher priority than a Task).

  • Either a rtos clock or a general purpose timer hwi can be used to post a semaphore and wake up a task OR they can use Task_setPri() function to raise a tasks' priority to run. You should be able to achieve timeslicing in this way.
  • Here's a discussion about how to achieve a round robin scheme instead of preemptive with the TI-RTOS kernel: