简体   繁体   English

在FreeRTOS中实施两项任务,结果出乎意料

[英]Implementing two tasks in FreeRTOS, unexpected results

I am trying to run two tasks using FreeRTOS APIs. 我正在尝试使用FreeRTOS API运行两个任务。 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. 我遵循了FreeRTOS的Handson 教程pdf ,但是我的任务只运行了一次就停止了。我在x86 Intel上使用FreeRTOS内核。 I am able to compie and run the code. 我能够编译并运行代码。

My OS is Ubuntu, I am using Eclipse Toolchain with GCC. 我的操作系统是Ubuntu,我在GCC中使用Eclipse Toolchain。 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)" 仅创建了一个任务,添加了vTaskDelay ,并且出现错误“分段故障(核心已转储)”

Which port are you using? 您正在使用哪个端口? Or are you trying to run the code on Ubuntu? 还是您正在尝试在Ubuntu上运行代码? The projects in the book are configured to run on Windows. 本书中的项目配置为在Windows上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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