mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-31 16:27:03 +08:00
fix(os): add support for thread names (#7579)
Signed-off-by: Cristian Stoica <cristianmarian.stoica@nxp.com>
This commit is contained in:
@@ -75,7 +75,7 @@ handle the supported draw tasks.
|
|||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
#if LV_USE_PXP_DRAW_THREAD
|
#if LV_USE_PXP_DRAW_THREAD
|
||||||
lv_thread_init(&draw_pxp_unit->thread, LV_THREAD_PRIO_HIGH, _pxp_render_thread_cb, 2 * 1024, draw_pxp_unit);
|
lv_thread_init(&draw_pxp_unit->thread, "pxpdraw", LV_THREAD_PRIO_HIGH, _pxp_render_thread_cb, 2 * 1024, draw_pxp_unit);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
If `LV_USE_PXP_DRAW_THREAD` is not defined, then no additional draw thread will be created
|
If `LV_USE_PXP_DRAW_THREAD` is not defined, then no additional draw thread will be created
|
||||||
@@ -274,7 +274,7 @@ handle the supported draw tasks.
|
|||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
#if LV_USE_VGLITE_DRAW_THREAD
|
#if LV_USE_VGLITE_DRAW_THREAD
|
||||||
lv_thread_init(&draw_vglite_unit->thread, LV_THREAD_PRIO_HIGH, _vglite_render_thread_cb, 2 * 1024, draw_vglite_unit);
|
lv_thread_init(&draw_vglite_unit->thread, "vglitedraw", LV_THREAD_PRIO_HIGH, _vglite_render_thread_cb, 2 * 1024, draw_vglite_unit);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
If `LV_USE_VGLITE_DRAW_THREAD` is not defined, then no additional draw thread will be created
|
If `LV_USE_VGLITE_DRAW_THREAD` is not defined, then no additional draw thread will be created
|
||||||
|
|||||||
@@ -36,10 +36,11 @@
|
|||||||
* GLOBAL FUNCTIONS
|
* GLOBAL FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
lv_result_t lv_thread_init(lv_thread_t * thread, lv_thread_prio_t prio, void (*callback)(void *), size_t stack_size,
|
lv_result_t lv_thread_init(lv_thread_t * thread, const char * const name, lv_thread_prio_t prio, void (*callback)(void *), size_t stack_size,
|
||||||
void * user_data)
|
void * user_data)
|
||||||
{
|
{
|
||||||
LV_UNUSED(thread);
|
LV_UNUSED(thread);
|
||||||
|
LV_UNUSED(name);
|
||||||
LV_UNUSED(callback);
|
LV_UNUSED(callback);
|
||||||
LV_UNUSED(prio);
|
LV_UNUSED(prio);
|
||||||
LV_UNUSED(stack_size);
|
LV_UNUSED(stack_size);
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ void lv_example_osal(void)
|
|||||||
LV_LOG_ERROR("Error initializing thread sync");
|
LV_LOG_ERROR("Error initializing thread sync");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lv_thread_init(&increment_thread, LV_THREAD_PRIO_MID, increment_thread_entry, 2048, NULL) != LV_RESULT_OK) {
|
if(lv_thread_init(&increment_thread, "inc_th", LV_THREAD_PRIO_MID, increment_thread_entry, 2048,
|
||||||
|
NULL) != LV_RESULT_OK) {
|
||||||
LV_LOG_ERROR("Error initializing thread");
|
LV_LOG_ERROR("Error initializing thread");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ void lv_draw_dma2d_init(void)
|
|||||||
#if LV_DRAW_DMA2D_ASYNC
|
#if LV_DRAW_DMA2D_ASYNC
|
||||||
g_unit = draw_dma2d_unit;
|
g_unit = draw_dma2d_unit;
|
||||||
|
|
||||||
lv_result_t res = lv_thread_init(&draw_dma2d_unit->thread, LV_THREAD_PRIO_HIGH, thread_cb, 2 * 1024, draw_dma2d_unit);
|
lv_result_t res = lv_thread_init(&draw_dma2d_unit->thread, "dma2d", LV_THREAD_PRIO_HIGH, thread_cb, 2 * 1024,
|
||||||
|
draw_dma2d_unit);
|
||||||
LV_ASSERT(res == LV_RESULT_OK);
|
LV_ASSERT(res == LV_RESULT_OK);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ void lv_draw_nema_gfx_init(void)
|
|||||||
|
|
||||||
|
|
||||||
#if LV_USE_OS
|
#if LV_USE_OS
|
||||||
lv_thread_init(&draw_nema_gfx_unit->thread, LV_THREAD_PRIO_HIGH, nema_gfx_render_thread_cb, 2 * 1024,
|
lv_thread_init(&draw_nema_gfx_unit->thread, "nemagfx", LV_THREAD_PRIO_HIGH, nema_gfx_render_thread_cb, 2 * 1024,
|
||||||
draw_nema_gfx_unit);
|
draw_nema_gfx_unit);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ void lv_draw_pxp_init(void)
|
|||||||
draw_pxp_unit->base_unit.name = "NXP_PXP";
|
draw_pxp_unit->base_unit.name = "NXP_PXP";
|
||||||
|
|
||||||
#if LV_USE_PXP_DRAW_THREAD
|
#if LV_USE_PXP_DRAW_THREAD
|
||||||
lv_thread_init(&draw_pxp_unit->thread, LV_THREAD_PRIO_HIGH, _pxp_render_thread_cb, 2 * 1024, draw_pxp_unit);
|
lv_thread_init(&draw_pxp_unit->thread, "pxpdraw", LV_THREAD_PRIO_HIGH, _pxp_render_thread_cb, 2 * 1024, draw_pxp_unit);
|
||||||
#endif
|
#endif
|
||||||
#endif /*LV_USE_DRAW_PXP*/
|
#endif /*LV_USE_DRAW_PXP*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,8 @@ void lv_draw_vglite_init(void)
|
|||||||
draw_vglite_unit->base_unit.name = "NXP_VGLITE";
|
draw_vglite_unit->base_unit.name = "NXP_VGLITE";
|
||||||
|
|
||||||
#if LV_USE_VGLITE_DRAW_THREAD
|
#if LV_USE_VGLITE_DRAW_THREAD
|
||||||
lv_thread_init(&draw_vglite_unit->thread, LV_THREAD_PRIO_HIGH, _vglite_render_thread_cb, 2 * 1024, draw_vglite_unit);
|
lv_thread_init(&draw_vglite_unit->thread, "vglitedraw", LV_THREAD_PRIO_HIGHEST, _vglite_render_thread_cb, 2 * 1024,
|
||||||
|
draw_vglite_unit);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ void lv_draw_dave2d_init(void)
|
|||||||
lv_ll_init(&_ll_Dave2D_Tasks, 4);
|
lv_ll_init(&_ll_Dave2D_Tasks, 4);
|
||||||
|
|
||||||
#if LV_USE_OS
|
#if LV_USE_OS
|
||||||
lv_thread_init(&draw_dave2d_unit->thread, LV_THREAD_PRIO_HIGH, _dave2d_render_thread_cb, 8 * 1024, draw_dave2d_unit);
|
lv_thread_init(&draw_dave2d_unit->thread, "dave2d", LV_THREAD_PRIO_HIGH, _dave2d_render_thread_cb, 8 * 1024,
|
||||||
|
draw_dave2d_unit);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ void lv_draw_sw_init(void)
|
|||||||
draw_sw_unit->base_unit.name = "SW";
|
draw_sw_unit->base_unit.name = "SW";
|
||||||
|
|
||||||
#if LV_USE_OS
|
#if LV_USE_OS
|
||||||
lv_thread_init(&draw_sw_unit->thread, LV_THREAD_PRIO_HIGH, render_thread_cb, LV_DRAW_THREAD_STACK_SIZE, draw_sw_unit);
|
lv_thread_init(&draw_sw_unit->thread, "swdraw", LV_THREAD_PRIO_HIGH, render_thread_cb, LV_DRAW_THREAD_STACK_SIZE,
|
||||||
|
draw_sw_unit);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,11 @@
|
|||||||
* GLOBAL FUNCTIONS
|
* GLOBAL FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
lv_result_t lv_thread_init(lv_thread_t * thread, lv_thread_prio_t prio, void (*callback)(void *), size_t stack_size,
|
lv_result_t lv_thread_init(lv_thread_t * thread, const char * const name, lv_thread_prio_t prio,
|
||||||
|
void (*callback)(void *), size_t stack_size,
|
||||||
void * user_data)
|
void * user_data)
|
||||||
{
|
{
|
||||||
|
LV_UNUSED(name);
|
||||||
static const osPriority_t prio_map[] = {
|
static const osPriority_t prio_map[] = {
|
||||||
[LV_THREAD_PRIO_LOWEST] = osPriorityLow,
|
[LV_THREAD_PRIO_LOWEST] = osPriorityLow,
|
||||||
[LV_THREAD_PRIO_LOW] = osPriorityBelowNormal,
|
[LV_THREAD_PRIO_LOW] = osPriorityBelowNormal,
|
||||||
|
|||||||
@@ -26,9 +26,6 @@
|
|||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
#define ulMAX_COUNT 10U
|
#define ulMAX_COUNT 10U
|
||||||
#ifndef pcTASK_NAME
|
|
||||||
#define pcTASK_NAME "lvglDraw"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define globals LV_GLOBAL_DEFAULT()
|
#define globals LV_GLOBAL_DEFAULT()
|
||||||
|
|
||||||
@@ -85,7 +82,8 @@ static void prvTestAndDecrement(lv_thread_sync_t * pxCond,
|
|||||||
* GLOBAL FUNCTIONS
|
* GLOBAL FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
lv_result_t lv_thread_init(lv_thread_t * pxThread, lv_thread_prio_t xSchedPriority,
|
lv_result_t lv_thread_init(lv_thread_t * pxThread, const char * const name,
|
||||||
|
lv_thread_prio_t xSchedPriority,
|
||||||
void (*pvStartRoutine)(void *), size_t usStackSize,
|
void (*pvStartRoutine)(void *), size_t usStackSize,
|
||||||
void * xAttr)
|
void * xAttr)
|
||||||
{
|
{
|
||||||
@@ -94,7 +92,7 @@ lv_result_t lv_thread_init(lv_thread_t * pxThread, lv_thread_prio_t xSchedPriori
|
|||||||
|
|
||||||
BaseType_t xTaskCreateStatus = xTaskCreate(
|
BaseType_t xTaskCreateStatus = xTaskCreate(
|
||||||
prvRunThread,
|
prvRunThread,
|
||||||
pcTASK_NAME,
|
name,
|
||||||
(configSTACK_DEPTH_TYPE)(usStackSize / sizeof(StackType_t)),
|
(configSTACK_DEPTH_TYPE)(usStackSize / sizeof(StackType_t)),
|
||||||
(void *)pxThread,
|
(void *)pxThread,
|
||||||
tskIDLE_PRIORITY + xSchedPriority,
|
tskIDLE_PRIORITY + xSchedPriority,
|
||||||
|
|||||||
+3
-2
@@ -37,7 +37,8 @@
|
|||||||
* GLOBAL FUNCTIONS
|
* GLOBAL FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
lv_result_t lv_thread_init(lv_thread_t * thread, lv_thread_prio_t prio, void (*callback)(void *), size_t stack_size,
|
lv_result_t lv_thread_init(lv_thread_t * thread, const char * const name, lv_thread_prio_t prio,
|
||||||
|
void (*callback)(void *), size_t stack_size,
|
||||||
void * user_data)
|
void * user_data)
|
||||||
{
|
{
|
||||||
TASK_TEMPLATE_STRUCT task_template;
|
TASK_TEMPLATE_STRUCT task_template;
|
||||||
@@ -47,7 +48,7 @@ lv_result_t lv_thread_init(lv_thread_t * thread, lv_thread_prio_t prio, void (*c
|
|||||||
task_template.TASK_ADDRESS = (TASK_FPTR)callback;
|
task_template.TASK_ADDRESS = (TASK_FPTR)callback;
|
||||||
task_template.TASK_STACKSIZE = stack_size;
|
task_template.TASK_STACKSIZE = stack_size;
|
||||||
task_template.TASK_PRIORITY = _sched_get_min_priority(0) - prio;
|
task_template.TASK_PRIORITY = _sched_get_min_priority(0) - prio;
|
||||||
task_template.TASK_NAME = "lvglDraw";
|
task_template.TASK_NAME = name;
|
||||||
task_template.CREATION_PARAMETER = (uint32_t)user_data;
|
task_template.CREATION_PARAMETER = (uint32_t)user_data;
|
||||||
|
|
||||||
*thread = _task_create(0, 0, (uint32_t)&task_template);
|
*thread = _task_create(0, 0, (uint32_t)&task_template);
|
||||||
|
|||||||
+6
-4
@@ -70,13 +70,15 @@ typedef enum {
|
|||||||
/**
|
/**
|
||||||
* Create a new thread
|
* Create a new thread
|
||||||
* @param thread a variable in which the thread will be stored
|
* @param thread a variable in which the thread will be stored
|
||||||
|
* @param name the name of the thread
|
||||||
* @param prio priority of the thread
|
* @param prio priority of the thread
|
||||||
* @param callback function of the thread
|
* @param callback function of the thread
|
||||||
* @param stack_size stack size in bytes
|
* @param stack_size stack size in bytes
|
||||||
* @param user_data arbitrary data, will be available in the callback
|
* @param user_data arbitrary data, will be available in the callback
|
||||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
||||||
*/
|
*/
|
||||||
lv_result_t lv_thread_init(lv_thread_t * thread, lv_thread_prio_t prio, void (*callback)(void *), size_t stack_size,
|
lv_result_t lv_thread_init(lv_thread_t * thread, const char * const name,
|
||||||
|
lv_thread_prio_t prio, void (*callback)(void *), size_t stack_size,
|
||||||
void * user_data);
|
void * user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -187,11 +189,11 @@ void lv_unlock(void);
|
|||||||
* optimizations and avoid the call overhead of the OS API to ensure no performance penalty.
|
* optimizations and avoid the call overhead of the OS API to ensure no performance penalty.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline lv_result_t lv_thread_init(lv_thread_t * thread, lv_thread_prio_t prio, void (*callback)(void *),
|
static inline lv_result_t lv_thread_init(lv_thread_t * thread, const char * const name, lv_thread_prio_t prio,
|
||||||
size_t stack_size,
|
void (*callback)(void *), size_t stack_size, void * user_data)
|
||||||
void * user_data)
|
|
||||||
{
|
{
|
||||||
LV_UNUSED(thread);
|
LV_UNUSED(thread);
|
||||||
|
LV_UNUSED(name);
|
||||||
LV_UNUSED(callback);
|
LV_UNUSED(callback);
|
||||||
LV_UNUSED(prio);
|
LV_UNUSED(prio);
|
||||||
LV_UNUSED(stack_size);
|
LV_UNUSED(stack_size);
|
||||||
|
|||||||
@@ -38,9 +38,11 @@ static void * generic_callback(void * user_data);
|
|||||||
* GLOBAL FUNCTIONS
|
* GLOBAL FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
lv_result_t lv_thread_init(lv_thread_t * thread, lv_thread_prio_t prio, void (*callback)(void *), size_t stack_size,
|
lv_result_t lv_thread_init(lv_thread_t * thread, const char * const name, lv_thread_prio_t prio,
|
||||||
|
void (*callback)(void *), size_t stack_size,
|
||||||
void * user_data)
|
void * user_data)
|
||||||
{
|
{
|
||||||
|
LV_UNUSED(name);
|
||||||
LV_UNUSED(prio);
|
LV_UNUSED(prio);
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
|
|||||||
@@ -38,10 +38,11 @@
|
|||||||
* GLOBAL FUNCTIONS
|
* GLOBAL FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
lv_result_t lv_thread_init(lv_thread_t * thread, lv_thread_prio_t prio, void (*callback)(void *), size_t stack_size,
|
lv_result_t lv_thread_init(lv_thread_t * thread, const char * const name, lv_thread_prio_t prio,
|
||||||
|
void (*callback)(void *), size_t stack_size,
|
||||||
void * user_data)
|
void * user_data)
|
||||||
{
|
{
|
||||||
thread->thread = rt_thread_create("thread",
|
thread->thread = rt_thread_create(name,
|
||||||
callback,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
stack_size,
|
stack_size,
|
||||||
|
|||||||
+3
-3
@@ -38,13 +38,13 @@ static int generic_callback(void * user_data);
|
|||||||
* GLOBAL FUNCTIONS
|
* GLOBAL FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
lv_result_t lv_thread_init(lv_thread_t * thread, lv_thread_prio_t prio, void (*callback)(void *), size_t stack_size,
|
lv_result_t lv_thread_init(lv_thread_t * thread, const char * const name, lv_thread_prio_t prio,
|
||||||
void * user_data)
|
void (*callback)(void *), size_t stack_size, void * user_data)
|
||||||
{
|
{
|
||||||
LV_UNUSED(prio);
|
LV_UNUSED(prio);
|
||||||
thread->callback = callback;
|
thread->callback = callback;
|
||||||
thread->user_data = user_data;
|
thread->user_data = user_data;
|
||||||
thread->thread = SDL_CreateThreadWithStackSize(generic_callback, "LVGL", stack_size, thread);
|
thread->thread = SDL_CreateThreadWithStackSize(generic_callback, name, stack_size, thread);
|
||||||
if(thread->thread == NULL) {
|
if(thread->thread == NULL) {
|
||||||
LV_LOG_ERROR("Error: %s", SDL_GetError());
|
LV_LOG_ERROR("Error: %s", SDL_GetError());
|
||||||
return LV_RESULT_INVALID;
|
return LV_RESULT_INVALID;
|
||||||
|
|||||||
@@ -46,11 +46,13 @@ static unsigned __stdcall thread_start_routine(void * parameter);
|
|||||||
|
|
||||||
lv_result_t lv_thread_init(
|
lv_result_t lv_thread_init(
|
||||||
lv_thread_t * thread,
|
lv_thread_t * thread,
|
||||||
|
const char * const name,
|
||||||
lv_thread_prio_t prio,
|
lv_thread_prio_t prio,
|
||||||
void (*callback)(void *),
|
void (*callback)(void *),
|
||||||
size_t stack_size,
|
size_t stack_size,
|
||||||
void * user_data)
|
void * user_data)
|
||||||
{
|
{
|
||||||
|
LV_UNUSED(name);
|
||||||
if(!thread) {
|
if(!thread) {
|
||||||
return LV_RESULT_INVALID;
|
return LV_RESULT_INVALID;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user