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.

Creating 2 tasks and just one executes

Other Parts Discussed in Thread: SYSBIOS

Hello. I'm trying to have two independent tasks in a SYSBIOS project. I opened the task example and works fine, but I copy paste my code in that project and I just can get 1 of the tasks running (the one I configure with priority 1). My question is, I don't have to care about the execution of the tasks right? I don't have to use a sempahore if they don't share any peripheral.... so I don't really get how come it usually just works 1 of the tasks.

  • Carlos,

    You do need to think about/plan the execution of the tasks.  If you haven’t seen it, section 3.5.2 “Task Execution States and Scheduling” in Bios_User_Guide.pdf has a good summary of the concepts.

    You don’t always need to use a Semaphore as in that example.  But if you want lower priority (or even the same priority) tasks to be able to run, then the highest priority task cannot just spin in a continuous loop.  It is only when the higher priority task blocks waiting for some condition (for example, a Semapore_post(), or sleeps for a while (Task_sleep()), or yields (Task_yield()), or completes (exits its function) that another task of the same or lower priority will be allowed to run.

    It sounds like the lower priority task is not getting to run because the new task is not doing one of the things listed above.  If you post your code (or at least the basics of the task functions) it will help to answer your question…

    Scott

  • Thanks so much Scott. That was exactly what I was wondering when I had the idea of creating a semaphore and so sadly this is what I wasn't expecting. I have two tasks that have to control two different power converters so I need them same priority and continuous loop. I thought that if i used a RTOS I would have some sort of Round Robin for multitasking and wouldn't have to think about priorities or stopping some task..... so I'm not sure now that all work I did migrating all my code to work with SYSBIOS is useful anymore, I could do the same without the RTOS then right?

  • Carlos,

    Section 3.5.6 of the SYS/BIOS User's Guide provides an example of how automatic time-slicing between tasks of the same priority can be achieved.

    Perhaps this might work for you.

    Essentially, you simply add a periodic Clock function that invokes Task_yield(). This results in the currently executing task being switched out and the next task OF THE SAME PRIORITY being switched in.

    Alan

  • Thanks Alan. I will take a look and probably it's gonna be useful. Now I was testing the code using a semaphore executing one loop of each task and using task_sleep on my highest one to let the other take the semaphore but I think time slicing is gonna be more useful and polish

  • Well i realized that using Task_yield() when I want to give priority to the other task it works... I didn't know that function hehe but is kid of the same as if I were not using SYSBIOS cause I don't use the RTOS for anything else