简体   繁体   中英

Implementing two tasks in FreeRTOS, unexpected results

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)"

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM