freertos

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

freertos

500 Views
wangyibin
Contributor II

在FreertosConfig.h的文件中有一个宏 :#define configUSE_TIME_SLICING 1。它的含义是:

为1使能时间片调度。(时间片调度是指每个进程被分配一个时间段,称作它的时间片,即该进程允许运行的时间。如果在时间片结束时进程还在运行,则CPU将被剥夺并分配给另一个进程。如果进程在时间片结束前阻塞或结束,则CPU当即进行切换。)

在配置文件中默认值为0,即不支持时间片轮转。我把这参数变为1,创建了两个相同优先级的任务,理想情况是这两个任务会交替执行。

但实验现象是:程序只运行其中一个任务,并且会在打印几次后死在哪里?

请问哪里有问题,还是需要更改其他额外的东西?

wangyibin_0-1659061438282.png

wangyibin_1-1659061515436.pngwangyibin_2-1659061530110.jpeg

 

Labels (1)
0 Kudos
1 Reply

485 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I think in the task loop, you have to have the code to block the task for example:

void vTaskFunction( void * pvParameters )
 {
 /* Block for 500ms. */
 const TickType_t xDelay = 500 / portTICK_PERIOD_MS;

     for( ;; )
     {
         /* Simply toggle the LED every 500ms, blocking between each toggle. */
         vToggleLED();
         vTaskDelay( xDelay );
     }
}
The line vTaskDelay( xDelay ); will block the task.
I think it is not okay using the code;

void vTaskFunction( void * pvParameters )
 {
 /* Block for 500ms. */
 const TickType_t xDelay = 500 / portTICK_PERIOD_MS;

     for( ;; )
     {
         /* Simply toggle the LED every 500ms, blocking between each toggle. */
         vToggleLED();
        // vTaskDelay( xDelay );
     }
}

Hope it can help you
BR
XiangJun Rong
 
0 Kudos