Skip to content

Commit d8292cb

Browse files
zyczcarlescufi
authored andcommitted
samples: coremark: Set cooperative priority for main thread
Drivers need to be run from non blocking thread. We need preemptive priority during init. Later we prefer cooperative priority to ensure no interference with benchmark. JIRA: NCSDK-30369 Signed-off-by: Jan Zyczkowski <[email protected]>
1 parent 66ab9ae commit d8292cb

File tree

6 files changed

+14
-10
lines changed

6 files changed

+14
-10
lines changed

samples/benchmarks/coremark/prj.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ CONFIG_CBPRINTF_FP_SUPPORT=y
2020

2121
CONFIG_GPIO=y
2222

23-
CONFIG_MAIN_THREAD_PRIORITY=-1
24-
2523
# Configuration variant:
2624
# Memory allocation using the stack memory
2725
# Single-threaded benchmark execution

samples/benchmarks/coremark/prj_flash_and_run.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ CONFIG_CBPRINTF_FP_SUPPORT=y
2020

2121
CONFIG_GPIO=y
2222

23-
CONFIG_MAIN_THREAD_PRIORITY=-1
24-
2523
# Configuration variant:
2624
# Memory allocation using the stack memory
2725
# Single-threaded benchmark execution

samples/benchmarks/coremark/prj_heap_memory.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ CONFIG_CBPRINTF_FP_SUPPORT=y
2020

2121
CONFIG_GPIO=y
2222

23-
CONFIG_MAIN_THREAD_PRIORITY=-1
24-
2523
# Configuration variant:
2624
# Memory allocation using the heap memory
2725
# Single-threaded benchmark execution

samples/benchmarks/coremark/prj_multiple_threads.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ CONFIG_CBPRINTF_FP_SUPPORT=y
2020

2121
CONFIG_GPIO=y
2222

23-
CONFIG_MAIN_THREAD_PRIORITY=-1
24-
2523
# Configuration variant:
2624
# Memory allocation using the stack memory
2725
# Multi-threaded benchmark execution

samples/benchmarks/coremark/prj_static_memory.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ CONFIG_CBPRINTF_FP_SUPPORT=y
2020

2121
CONFIG_GPIO=y
2222

23-
CONFIG_MAIN_THREAD_PRIORITY=-1
24-
2523
# Configuration variant:
2624
# Memory allocation using the static memory
2725
# Single-threaded benchmark execution

samples/benchmarks/coremark/src/main.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
LOG_MODULE_REGISTER(app, LOG_LEVEL_INF);
1717

18+
#define COOP_PRIO -1
19+
1820
#ifndef CONFIG_APP_MODE_FLASH_AND_RUN
1921
/*
2022
* Get button configuration from the devicetree. This is mandatory.
@@ -170,8 +172,20 @@ static int button_init(void)
170172
return ret;
171173
}
172174

175+
static void main_thread_priority_cooperative_set(void)
176+
{
177+
BUILD_ASSERT(CONFIG_MAIN_THREAD_PRIORITY >= 0);
178+
k_thread_priority_set(k_current_get(), COOP_PRIO);
179+
}
180+
173181
int main(void)
174182
{
183+
/* Drivers need to be run from a non-blocking thread.
184+
* We need preemptive priority during init.
185+
* Later we prefer cooperative priority to ensure no interference with the benchmark.
186+
*/
187+
main_thread_priority_cooperative_set();
188+
175189
LOG_INF("CoreMark sample for %s", CONFIG_BOARD_TARGET);
176190

177191
if (IS_ENABLED(CONFIG_APP_MODE_FLASH_AND_RUN)) {

0 commit comments

Comments
 (0)