From 79a030ec5033443aecc9f4b097341de7fbdff518 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 1 Dec 2015 12:04:34 +0100 Subject: [PATCH] Work threads: Ensure they have proper names --- src/platforms/posix/work_queue/work_thread.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/platforms/posix/work_queue/work_thread.c b/src/platforms/posix/work_queue/work_thread.c index ec565bcfcc..406e350341 100644 --- a/src/platforms/posix/work_queue/work_thread.c +++ b/src/platforms/posix/work_queue/work_thread.c @@ -195,7 +195,7 @@ void work_queues_init(void) #endif // Create high priority worker thread - g_work[HPWORK].pid = px4_task_spawn_cmd("wkr_high", + g_work[HPWORK].pid = px4_task_spawn_cmd("hpwork", SCHED_DEFAULT, SCHED_PRIORITY_MAX - 1, 2000, @@ -203,7 +203,7 @@ void work_queues_init(void) (char *const *)NULL); // Create low priority worker thread - g_work[LPWORK].pid = px4_task_spawn_cmd("wkr_low", + g_work[LPWORK].pid = px4_task_spawn_cmd("lpwork", SCHED_DEFAULT, SCHED_PRIORITY_MIN, 2000, @@ -306,6 +306,14 @@ int work_usrthread(int argc, char *argv[]) { /* Loop forever */ + int rv; + // set the threads name + #ifdef __PX4_DARWIN + rv = pthread_setname_np("USR"); + #else + rv = pthread_setname_np(pthread_self(), "USR"); + #endif + for (;;) { /* Then process queued work. We need to keep interrupts disabled while * we process items in the work list.