Skip to content

Commit f3a3ad3

Browse files
clamattiakartben
authored andcommitted
thread_analyzer: Allow to override the auto-analysis thread priority
By default the thread priority is still the lowest application thread priority. Allow the priority to be increase by specifying both, the `override` option as well as the desired `priority`. This pattern was taken from the shell thread. Signed-off-by: Cla Mattia Galliard <[email protected]>
1 parent 48f7fcd commit f3a3ad3

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

subsys/debug/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ config THREAD_ANALYZER_AUTO_STACK_SIZE
101101
default 2048 if THREAD_ANALYZER_USE_LOG && LOG_MODE_IMMEDIATE && NO_OPTIMIZATIONS
102102
default 1024
103103

104+
config THREAD_ANALYZER_AUTO_THREAD_PRIORITY_OVERRIDE
105+
bool "Override default thread analysis thread priority"
106+
help
107+
Option to change the default value of thread analysis thread priority.
108+
109+
if THREAD_ANALYZER_AUTO_THREAD_PRIORITY_OVERRIDE
110+
config THREAD_ANALYZER_AUTO_THREAD_PRIORITY
111+
int "Thread analysis thread priority"
112+
default 0
113+
help
114+
Set thread priority of the thread analysis
115+
endif # THREAD_ANALYZER_AUTO_THREAD_PRIORITY_OVERRIDE
116+
104117
endif # THREAD_ANALYZER_AUTO
105118

106119
endif # THREAD_ANALYZER

subsys/debug/thread_analyzer.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818

1919
LOG_MODULE_REGISTER(thread_analyzer, CONFIG_THREAD_ANALYZER_LOG_LEVEL);
2020

21+
#if CONFIG_THREAD_ANALYZER_AUTO_THREAD_PRIORITY_OVERRIDE
22+
#define AUTO_THREAD_PRIO CONFIG_THREAD_ANALYZER_AUTO_THREAD_PRIORITY
23+
#else
24+
#define AUTO_THREAD_PRIO K_LOWEST_APPLICATION_THREAD_PRIO
25+
#endif
26+
2127
#if defined(CONFIG_THREAD_ANALYZER_USE_PRINTK)
2228
#define THREAD_ANALYZER_PRINT(...) printk(__VA_ARGS__)
2329
#define THREAD_ANALYZER_FMT(str) str "\n"
@@ -265,7 +271,7 @@ static int thread_analyzer_init(void)
265271
CONFIG_THREAD_ANALYZER_AUTO_STACK_SIZE,
266272
thread_analyzer_auto,
267273
(void *) (uint32_t) i, NULL, NULL,
268-
K_LOWEST_APPLICATION_THREAD_PRIO, 0, K_FOREVER);
274+
AUTO_THREAD_PRIO, 0, K_FOREVER);
269275
if (!tid) {
270276
LOG_ERR("k_thread_create() failed for core %u", i);
271277
continue;
@@ -297,7 +303,7 @@ K_THREAD_DEFINE(thread_analyzer,
297303
CONFIG_THREAD_ANALYZER_AUTO_STACK_SIZE,
298304
thread_analyzer_auto,
299305
NULL, NULL, NULL,
300-
K_LOWEST_APPLICATION_THREAD_PRIO,
306+
AUTO_THREAD_PRIO,
301307
0, 0);
302308

303309
#endif /* CONFIG_THREAD_ANALYZER_AUTO_SEPARATE_CORES */

0 commit comments

Comments
 (0)