Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: sched: Add busy threads for SMP #81051

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/benchmarks/sched/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
static K_THREAD_STACK_DEFINE(partner_stack, 1024);
static struct k_thread partner_thread;

#if (CONFIG_MP_MAX_NUM_CPUS > 1)
static struct k_thread busy_thread[CONFIG_MP_MAX_NUM_CPUS - 1];

#define BUSY_THREAD_STACK_SIZE (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)

Check notice on line 43 in tests/benchmarks/sched/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

tests/benchmarks/sched/src/main.c:43 -#define BUSY_THREAD_STACK_SIZE (1024 + CONFIG_TEST_EXTRA_STACK_SIZE) +#define BUSY_THREAD_STACK_SIZE (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)
static K_THREAD_STACK_ARRAY_DEFINE(busy_thread_stack, CONFIG_MP_MAX_NUM_CPUS - 1,
BUSY_THREAD_STACK_SIZE);
#endif /* (CONFIG_MP_MAX_NUM_CPUS > 1) */

_wait_q_t waitq;

enum {
Expand Down Expand Up @@ -88,8 +97,26 @@
}
}

#if (CONFIG_MP_MAX_NUM_CPUS > 1)
static void busy_thread_entry(void *arg1, void *arg2, void *arg3)
{
while (true) {
}
}
#endif /* (CONFIG_MP_MAX_NUM_CPUS > 1) */

int main(void)
{
#if (CONFIG_MP_MAX_NUM_CPUS > 1)
/* Spawn busy threads that will execute on the other cores */
for (uint32_t i = 0; i < CONFIG_MP_MAX_NUM_CPUS - 1; i++) {
k_thread_create(&busy_thread[i], busy_thread_stack[i],
BUSY_THREAD_STACK_SIZE, busy_thread_entry,
NULL, NULL, NULL,
K_HIGHEST_THREAD_PRIO, 0, K_NO_WAIT);
}

Check notice on line 117 in tests/benchmarks/sched/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

tests/benchmarks/sched/src/main.c:117 - k_thread_create(&busy_thread[i], busy_thread_stack[i], - BUSY_THREAD_STACK_SIZE, busy_thread_entry, - NULL, NULL, NULL, - K_HIGHEST_THREAD_PRIO, 0, K_NO_WAIT); + k_thread_create(&busy_thread[i], busy_thread_stack[i], BUSY_THREAD_STACK_SIZE, + busy_thread_entry, NULL, NULL, NULL, K_HIGHEST_THREAD_PRIO, 0, + K_NO_WAIT);
#endif /* (CONFIG_MP_MAX_NUM_CPUS > 1) */

z_waitq_init(&waitq);

int main_prio = k_thread_priority_get(k_current_get());
Expand Down
Loading