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.

CCS/PROCESSOR-SDK-OMAPL137: Create two tasks with same priority and run those tasks for every 5msec concurrently

Part Number: PROCESSOR-SDK-OMAPL137

Tool/software: Code Composer Studio

I want to create two tasks lets say task1 and task2 with same priority and
those tasks(task1 and task2) has to run for every 5ms concurrently. If task1 is
running task2 has to wait until finshing of task1.
I have used following API Task_create and Clock_create to make it work.
Is there any better example when the two has same priority and run those tasks for every 5msec?

Thanks,

Gangadhar

  • You can have add a Clock function that runs every 5ms. It will post a semaphore twice. Then have each task call Semaphore_pend on the same semaphore at the top of their processing loop. You are correct one task will run before the other, but you cannot have two tasks actively running at the same time.

    How long will each task run for? Are you wanting to time-slice? By default, the TI-RTOS kernel is preemptive. There is a section in the SYS/BIOS User Guide that details this.

    Todd
  • Hi Todd,

    Thanks for your reply. I want to run each task(task1 and task2) 5msec and after some certain conditions met change the task1 to run either 10msec or even lesser and don't change the task2 time means it always runs at 5msec. Like that keep on change the task1 time based on conditions.

    Currently I have developed my example using time slice and event example of OMAPL137.

    And also is it possible to set fractional time period while creating clock handler using Clock_create API and as well as using Clock_setPeriod API.

    Thanks,

    Gangadhar

  • Hi Gangadhar,

    It sounds like you need two semaphores and two clock functions then to allow them to be at different rates. All clock functions must be a multiple of the Clock period (which is 1ms by default). So 5ms and 10ms are fine. You cannot do 5.5ms or 500us though unless you change the Clock period to a factor of those (e.g. 500us). Note: you get an interrupt for each clock tick, so you don't want to set it too low (otherwise you'll have too many interrupts to handle).

    Note for low power MCU devices, we have tick suppression and other tricks to minimize the number of interrupts. I'm including this comment in case someone looks at this thread but is using one of those devices.

    Todd

  • Hi Todd,

    Thanks for your suggestion.I am able to create and run two tasks at different rates using two semaphores and two clock functions. I don't want to set my clock period to factor of micro seconds, will always use fraction of msec only.

    I have one more requirement like is there any way we can change the rate of task1 at run time  by passing value from keyboard using scanf and that value can be used by  Clock_setPeriod API to change the rate of task1. I have tried using scanf but it's not working. Can you please let me know is there any other way we can pass the value and change it run time.

    Thanks,

    Gangadhar

  • Hi Gangadhar,

    Can you start a new thread about getting scanf to work? We try to keep the threads short to make them easier to search and read.

    Todd
  • Hi Todd,

    I have created one more thread regarding scanf issue. e2e.ti.com/.../621917