1 /*
2 * Copyright (c) 2016 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include "test_sched.h"
8
9 /* Shared threads */
10 K_THREAD_STACK_DEFINE(tstack, STACK_SIZE);
11 K_THREAD_STACK_ARRAY_DEFINE(tstacks, MAX_NUM_THREAD, STACK_SIZE);
12
13 /* Not in header file intentionally, see #16760 */
14 K_THREAD_STACK_DECLARE(ustack, STACK_SIZE);
15
spin_for_ms(int ms)16 void spin_for_ms(int ms)
17 {
18 uint32_t t32 = k_uptime_get_32();
19
20 while (k_uptime_get_32() - t32 < ms) {
21 /* In the posix arch, a busy loop takes no time, so
22 * let's make it take some
23 */
24 Z_SPIN_DELAY(50);
25 }
26 }
27
threads_scheduling_tests_setup(void)28 static void *threads_scheduling_tests_setup(void)
29 {
30 #ifdef CONFIG_USERSPACE
31 k_thread_access_grant(k_current_get(), &user_thread, &user_sem,
32 &ustack);
33 #endif /* CONFIG_USERSPACE */
34
35 return NULL;
36 }
37
38 /**
39 * @brief Test scheduling
40 *
41 * @defgroup kernel_sched_tests Scheduling Tests
42 *
43 * @ingroup all_tests
44 *
45 * @{
46 * @}
47 */
48 ZTEST_SUITE(threads_scheduling, NULL, threads_scheduling_tests_setup, NULL, NULL, NULL);
49 ZTEST_SUITE(threads_scheduling_1cpu, NULL, threads_scheduling_tests_setup,
50 ztest_simple_1cpu_before, ztest_simple_1cpu_after, NULL);
51