0
votes

I am trying to run two tasks using FreeRTOS APIs. I followed the Handson Tutorial pdf of FreeRTOS, but my task runs just once and stops.I am using the FreeRTOS kernel on x86 Intel. I am able to compie and run the code.

My OS is Ubuntu, I am using Eclipse Toolchain with GCC. If anyone has experience with this, they could give me some pointers as to how to do it right.

Here is my code:

static unsigned long uxQueueSendPassedCount = 0;

void vTask1(void *pvParameters)
{
   const char *str_to_display="This is task1\n\r";
   while(1)
   {
     printf("%s",str_to_display);
     vTaskDelay(1000);

   }

}

void vTask2(void *pvParameters)
{
    const char *str_to_display="This is task2\n\r";

    while(1)
    {
      printf("%s",str_to_display);
      vTaskDelay(1000);
    }

}

int main()
{

    xTaskCreate(vTask1, (signed char *)"Task1",1000,NULL,3,NULL);
    xTaskCreate(vTask2,(signed char *)"Task2",100,NULL,1,NULL);

    vTaskStartScheduler();
    while(1)
    {

    }
    return 0;

}

Update: Other things i tried :

  • Created just one task, with infinite loop and it runs as expected,

  • Created just one task, added vTaskDelay, and i get an error "Segmentation fault (core dumped)"

1
why is the posted code calling a delay function, asking for more delay time than the task execution rate interval? Such an extended delay will cause problems.user3629249
the task scheduling rate will already mean there is lots of delay between scheduling of the task. Calling a delay routine with such a large delay will result in problems.user3629249
the posted code does not cleanly compile! 1) missing the needed include statements for the needed header files 2) contains unused 'task' parameters. for each unused task parameter, as the first line in the task body, insert: (void)pvParameters;user3629249
Delay function inside a task simulates the execution time as far as i inderstand. It works now for Ubuntu, after i found a Demo for Uuntu, adapted my code. It ran fine.Abel Tom
You are giving your tasks almost no stack space. (the 3. parameter to xTaskCreate) Give them more. printf needs a lot of stack space.nos

1 Answers

0
votes

Which port are you using? Or are you trying to run the code on Ubuntu? The projects in the book are configured to run on Windows.