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_sleep

Hi,

We are implementing a task, It is observed with out a Task_Sleep() the Task Doesnot run,

As my application is time critical, we cannot include a Task_Sleep() of 1ms

Can you please suggest is there any way that

1) We can decrease the Task_sleep() time say in Micro seconds or else is there any API to execute in Micro seconds

2) Else can we assign a execution time for a task.

Regards,

Bindu

  • Bindu,

    I don't really understand your question. Do you have any other higher priority tasks running?

    What version of SYS/BIOS and XDCtools are you using?

  • Hi Tom,

    We are using  SYS/BIOS 6.24.4.22

    Let me put the question in this way.

    we create a task in this way

    Task_Params_init(&taskParams);

    taskParams.priority = 2;

    taskParams.stackSize = 1512;

    Task1TaskHndl = Task_create (Task1, &taskParams, NULL);

    Next for the task to execute

    void Task1 (UArg arg0, UArg arg1)

    {

    while (1)

    {

    //some exection steps

    Task_sleep(1);

    }

    }

    Our question is when there is no Task_sleep(1); included in Task1 : Task1 does not execute

    But i guess using this Task_sleep() API the minumum sleep time achieved is 1ms, but since our application is time critical we cannot include a sleep time of 1ms.

    Can you please suggest some other API that has a sleep time in micro seconds or else some other alternate.

    Regards,

    Bindu

  • HI Bindu,

    I think, whether Task1 is executable or not does not depend on the existence of Task_sleep(1) directly because Task_sleep is being executed on Task1 function itself. Task_sleep will never be called until Task1 is executed.

    As Tom suggested,  you can check whether more higher task is in active or not when Task1 is being blocked.
    SYS/BIOS gives CPU to tasks based on the priority, not based on the time. So if system has higher tasks than Task1, Task1 can be blocked.

    Regards,
    Kawada 

  • Hi Kawada,

    Thanks for the reply.

    Is there any other API which can be used to block in microseconds ?

    Since using Task_sleep minimum is 1 Milisecond i guess

    Regards,

    Bindu

  • HI Bindu,

    To answer your question, yes, I think you can use more smaller time for a tick.
    You give a tick as a parameter to Task_sleep and tick depends on Clock module.  

    The following link will be helpful.

    http://e2e.ti.com/support/embedded/bios/f/355/t/119836.aspx

    ..but I think you should check if the system has tasks having higher priority than Task1 and verify why Task is being blocked.

    Regards,
    Kawada 

  • Hi Kawada,

    Thanks for the reply.

    I'm new to RTOS

    Few doubt about below code :

    1) How to implement the below code, where?

    var ti_sysbios_knl_Clock = xdc.useModule('ti.sysbios.knl.Clock');
    ti_sysbios_knl_Clock.tickPeriod = 1000; //1ms.

     2) there is a lower priority task to run, other than task1

    3) Is there any way , that i do not disturb the other modules call to task_sleep (miliseconds), but mean while i can use them only applicable to my module for microsecond.

    Regards,

    Bindu

  • Hi Bindu,

    >1) How to implement the below code, where?

    First of all, you can check SYS/BIOS user's manual in your SYS/BIOS package. 
    Whenever you use SYS/BIOS, you have a configuration file (*.cfg) for SYS/BIOS. Please modify this file.

     >2) there is a lower priority task to run, other than task1

    If system has lower priority tasks than Task1, and if Task1's priority is the highest, Task1 will not be disturbed by other Tasks. But actually you could not confirm the control came to Task1. So I believe Task1 was in blocked state. Please note SYS/BIOS will give higher priority to task instances when giving higher value at the priority configuration So, in your case, if the system has tasks having lower priority, they must be configured with 1 or so. Please confirm Task1 is really having the higher priority in the system.

    >3) Is there any way , that i do not disturb the other modules call to task_sleep (miliseconds), but mean while i can use them only applicable to my module for microsecond.

    I don't understand this question.. By calling Task_sleep, Task switching will happen to give CPU to another task in ready. I'm not sure this behavior is your intension to use Task_sleep. And Clock module can be also referred from SYS/BIOS. So, if you change Clock configuration, this can give side-effects to other modules in your system.

    Regards,
    Kawada 

  • Hi Kawada,

    Thanks for the reply.

    1) Is there any other API apart from Task_sleep which works with microseconds.

    2) Can we assign a exection time to a task

    Example : Task1 with assign time in microseconds ( task1 should execute with in specified time period)

    Regards,

    Bindu

  • Hello Bindu,

    As I mentioned before, SYS/BIOS can't assign the exact time to the task instances.
    If you want to execute the function with specified time period, you can use Clock_create(...).
    Please confirm the SYS/BIOS user's guide and Cdoc.

    Hope this answer your question(s).

    Regards,
    Kawada

     

  • Hi Kawada,

    Thanks for the reply.

    1) What is the time perid ( clockParams.period ), is it in miliseconds ?

    2) Every clockParams.period , the task is scheduled ?

    Regards,

    Bindu

  • Hi Bindu,

    1) A period is specified in tick. A tick is defined with 1000us as default, and It can be configured with the different value in cfg file, for example :

    Clock.tickPeriod = 900; // A tick = 900 micro sec, rather than 1000 micro sec

    2) No. Clock thread is not actually Task instance, but a kind of Hwi. That's why Clock thread can be executed in the specified period. 

    Please check the documents in detail.

    Regards,
    Kawada 

  • Hi Kawada,

    I'm new to RTOS

    where can i find this cfg file?

    Regards,

    Bindu

  • Bindu,

    Have you already had the project working with sys/bios, right?  So you must have your configuration file (*.cfg) in your project tree on CCS project window. Also, as I mentioned you before, you can check the document at first.

    Regards,

    Kawada

  • Hi Kawada,

    Thanks, I got the *.cfg file and have modified in micro seconds.

    Now how can i check task_sleep is running with microseconds?

    Regards,

    Bindu

  • Hi Bindu,

    Changing the tick period to 1 us will introduce some extra overhead on your system. I think we need to look at the bigger problem: "Why does your Task run without a Task_sleep()?" If that's really the case, then there might be a real problem here.

    On what device are you running SYS/BIOS 6.24? It's a pretty old version....

    What exactly are you trying to do in your Task? Are you calling any other SYS/BIOS APIs in that task? How are you determining that the Task isn't running? Did you check ROV and see what task is currently being executed? ROV will also tell you if you have any other Tasks created.

  • Hi Tom,

    Actually there is 3 tasks

    Task1 with priority 6

    Task3 with priority 3

    We have created a new task Task2 with priority 5, Task2 is defined in this way

    void Task2 ()

    {

    while(1)

    {

    // SPI execution statements

    //Task_sleep (100 us);

    }

    }

    Task2 is executed only if there is a Task_sleep other wise not.

    2) One more observation if we include the //// SPI execution statements into Task1, this statments no longer gets executed. what can be the cause?

    3)Do Task gets executed with out a Task_Sleep??

    Regards,

    Bindu

  • Hi Bindu,

    a few things to note here.

    Bindu Ganesh said:
    3)Do Task gets executed with out a Task_Sleep??

    By definition, the highest priority task that can run, will run. A Task_sleep() is not required for task execution; but by adding it, it should cause the opposite effect. By having a Task_sleep() will allow lower priority tasks to execute; assuming they aren't blocked.

    Bindu Ganesh said:

    Void Task2 ()
    {
        while(1) { <-- Insert breakpoint here
        // SPI execution statements
        }
    }

    Can you see if your application can run to Task2's while(1) loop (when it doesn't have the Task_sleep() in it) using a breakpoint?

    Bindu Ganesh said:
    2) One more observation if we include the //// SPI execution statements into Task1, this statments no longer gets executed.

    You may want to look into the nature of these calls to SPI. Often, they are blocking type of statements in which they have while() loops that wait for transmit/receive data registers to be ready. To add to that, if you're using SPI as an SPI slave, you are at the mercy of SPI master to receive/transmit data.

  • Hi Tom,

    1) Can you see if your application can run to Task2's while(1) loop (when it doesn't have the Task_sleep() in it) using a breakpoint?

    Yes, application will run till while(1), but the further execution steps are not exectued ( If task_sleep() is not included)

    2)If we have 3 tasks

    task1(), task2(), task3() : if we initialize these 3 tasks

    task1 clock period 1 ms;

    task2 clock period 2 ms;

    task3 clock period 3 ms;

    then, task 1 will run every 1 ms interval?

    task2 will run after completion of task1?

    task3 will run after completion of task3? how do the exection takes place

    3) In my application task1 should execte completely later task2 and then task3..

    how can this be achieved?

     

    Regards,

    Bindu

  • Bindu,

    It looks like this post is referring to another thread here.