Multiple task running at same time issue in lv_task

Created 3 different tasks with three different functions each in 20ms time period. But three tasks are not running simultaneously. One task created for updating chart, second task for updating numbers and 3rd task for updating numbers. all the priorities for the task also given same.

void function_task_cb(lv_task_t task)
graph_data = graph_data + rand()%100;
graph_data2 = graph_data2 + rand()%100;
void function_task_cb_1(lv_task_t task)
lv_label_set_text_fmt(label_data5,"%d%", 250);
lv_label_set_text_fmt(label_data6,"%d%", 300);
void function_task_cb_2(lv_task_t task)
lv_label_set_text_fmt(label_data2,"%d%", 40);
lv_label_set_text_fmt(label_data3,"%d%", 15);
void fun_task(void)
lv_task_t* task = lv_task_create(function_task_cb,20,LV_TASK_PRIO_MID,NULL);

lv_task_t* task_1 = lv_task_create(function_task_cb_1,20,LV_TASK_PRIO_MID,NULL);

lv_task_t* task_2 = lv_task_create(function_task_cb_2,20,LV_TASK_PRIO_MID,NULL);


But three tasks are not running simultaneously.

I am not sure if this was a question, observation. But if this was a question around why they are not running simultaneously… Then I believe that the tasks are non-preemptive. The documentation does not state if it will use one core or all the cores available when creating tasks, but assuming you have one CPU and LVGL does not create tasks on different cores available then tasks wont interrupt each other and thus will not run simultaneously.
Look into the source how this is handled, or perhaps somebody else has an additional comment…

1 Like

three tasks period is same,why not do it in one task?

I need two task work at different timer(ms). one task in 20ms updating data and other task in 100ms updating data. I debug the program but 20ms and 100ms not properly occur the task function. Show tested debug process for two task in 20ms. But two task does not work at same time.


this above lvgl library function inside use millisecond timer. I am use this lvgl library timer.

How to create different timer(ms) for lv_task ?

any possible different timer use for for lv_task function without lv_task_create().

@rvt is correct: LVGL tasks are not preemptive. They do not run in parallel (and cannot fake the appearance of concurrency like an OS can).

If you need tasks to appear to run at the same time, you will need to look into adding an RTOS like FreeRTOS.

1 Like