problems on same priority tasks

saravanan85 wrote on Saturday, March 01, 2008:

Hi all,
       I have working with i.MX27 multimedia application processor.I am using FreeRTOS v4.7.1 and IAR embedded workbench v5.11 for my project.I am newbie to the FreeRTOS.I have created simply 3 tasks and assign the priorities.there is no problem when tasks have different priotities.
       But if i assign the same priority for 2 or 3 tasks,it will point out last priority task only.if task 1 and 2 have same priority,it points 2nd task only or tasks 1&3 or 2&3 have same priority,it points 3rd task only.
       I dont know what will happened on 2 or more tasks have the same priority.so anyone suggest idea for my problem.

regards,
saravanan.r

rtel wrote on Saturday, March 01, 2008:

Do you have configUSE_PREEMPTION set to 1 in FreeRTOSConfig.h?

If so, can you create three very simple tasks (may that do nothing but flash an LED each, then sleep) that have a similar structure to your real tasks to see if these run as expected - and if not post the code for these simple tasks here.

Regards.

saravanan85 wrote on Monday, March 03, 2008:

Hi richardbarry,
        Thanks for your quick reply.Now i am currently working in IAR Embedded Workbench v5.11 simulator.I have no any hardware device.so i cant able to check in hardware device.I have write my piece of code here.

#include "FreeRTOS.h"
#include "task.h"

#define TASK1_PRIORITY     ( tskIDLE_PRIORITY + 2)
#define TASK2_PRIORITY     ( tskIDLE_PRIORITY + 3)
#define TASK3_PRIORITY   ( tskIDLE_PRIORITY + 4)

main()
{
    xTaskCreate( TASK1,"CHECK", configMINIMAL_STACK_SIZE, NULL,TASK1_PRIORITY,NULL);
    xTaskCreate( TASK2,"LCD",configMINIMAL_STACK_SIZE, NULL,TASK2_PRIORITY, NULL);
    xTaskCreate( TASK3,"MSG", configMINIMAL_STACK_SIZE,NULL,TASK3_PRIORITY, NULL);
    vTaskStartScheduler();
    for(;:wink:
}
static void TASK1( void *pvParameters )
{
int i=0;
for()
{
   i++;
   -------task code here---------------
}
}

static void TASK2( void *pvParameters )
{
int j=0;
for()
{
   j++;
   -------task code here---------------
}
}
static void TASK3( void *pvParameters )
{
int k=0;
for()
{
   k++;
   -------task code here---------------
}
}

Yes,i have configUSE_PREEMPTION set to 1 in FreeRTOSConfig.h.If i have assign the same priorities for tasks 2&3 or 1&3,scheduler points k++(task3)only.it will go to j++(task2) or i++(task1)respectively, when i suspend the 3rd task only.what will happened if a one of the task has same priority.

Regards,
saravanan.r

bkastel1 wrote on Monday, March 03, 2008:

Hello,

maybe it is just a typing mistake but your for() loop is missing ; - it should be for(;;){}. And also you should have a wait condition of somekind - maybe just a vTaskDelay(some_ticks); . Otherwise your highest task will not do a context switch to a task of lower priority.

regards,

Borut

rtel wrote on Monday, March 03, 2008:

The IAR simulator is a core only simulator.  This means it does not simulate the timer and therefore the tick interrupt will not be executing.  Without the tick interrupt you will never switch tasks unless you use a taskYIELD() statement - I’m not sure if the yielding works in the simulator but I would guess that it did.

Regards.