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 switching in SYS/BIOS

Other Parts Discussed in Thread: CC2650

Hi

 

I have a question regarding the behaiviour of SYS/BIOS when two threads with the same priority are ready to run.

say you have three threads, task1,task2 and task3. task1 and 2 have priority 5 and task3 have priority 10.

If task1 is running, task2 is ready to run, and then task3 preempts task1 for a short while. When task3 finally gets blocked, which task does SYS/BIOS schedule? task1 or task2?

 

BR

Niklas 

  • task1 will run.


    When a task is preempted by a higher priority task, the preempted task gets effectively placed at the _front_ of it's ready queue.   It will run before any other threads of the same priority.  Tasks of equal priority to that task will not run until the first task blocks on a call to Semaphore_pend() or Task_sleep() or some such.  

    This is important since you can use thread priority as a cheap form of mutex.  2 threads of equal priority can share a resource (like some scratch memory or some other rsources) without worrying about the other thread.  The only way the other thread will run is if the first thread blocks.

    Regards,
    -Karl-

  • Thanks Karl

    This was a really good answer

    /Niklas

  • Hello Karl,
    I am speaking in regards to cc2650 launchpad and TI-RTOS.I tried to combine aspects of heart rate and project zero in the same project.

    The project zero was being used to toggle LEDs through an android Application where it was also storing the log of the time and mobile number which toggled the led.

    I wanted to transmit this stored log, so i tried to combined the heart rate with my project zero.

    If I define 2 tasks in a same project, for example two separate functions for Project Zero and Heart Rate, can I share memory between the two functions? Right now I am defining all the functions in the same task.

    If the memory sharing is not possible, is it possible to define two separate tasks for project zero and heart rate in the same project and use the task switch option, if any , to get the cc2650launchpad to transmit the datalog to the smartphone. Essentially, the heart rate task fxn will be used as a transmitter. Please let me know your views on this. Sorry to trouble you.

    I understand that my end application might require memory sharing between these two functions since task 1 will store the log and task 2 will transmit it . But I can't wrap my head around how to do it.

    Please Help.

    Regards,
    Keyshav
  • Hi Keyshav,
    We generally discourage posting a new question to an old closed thread because the person who answered before may no longer be available, and also it will allow whomever is currently assigned to monitor the forum to respond to you more quickly. For these reasons, I suggest you start a new thread with your question and reference this thread.

    Thank you