Skip to content

Commit 2af77dd

Browse files
committed
SCHED_CONTEXT_0014: Use sel4utils thread directly
start_helper would do unnecessary complicated thread startup code which may contain FPU instructions with some compilers and configs. Normally this would be harmless (though it would thwart the test's intention), but if the task runs out of budget before it finishes the FPU instruction, it will be put on the release queue and make no forward progress (unclear why). This is only a problem for tasks with budget equal to MIN_BUDGET, any time lost because of syscalls or traps will cause the task to hang. Signed-off-by: Indan Zupancic <indan@nul.nu>
1 parent 916ecab commit 2af77dd

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

apps/sel4test-tests/src/tests/schedcontext.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,10 @@ test_revoke_sched_context_on_call_chain(env_t env)
732732
DEFINE_TEST(SCHED_CONTEXT_0013, "Test revoking a scheduling context on a call chain",
733733
test_revoke_sched_context_on_call_chain, config_set(CONFIG_KERNEL_MCS) &&config_set(CONFIG_HAVE_TIMER))
734734

735-
void sched_context_0014_helper_fn(_Atomic seL4_Word *counter)
735+
void sched_context_0014_helper_fn(void *arg0, void *arg1, void *ipc_buf)
736736
{
737+
_Atomic seL4_Word *counter = arg0;
738+
737739
while (1) {
738740
(*counter)++;
739741
}
@@ -742,24 +744,32 @@ void sched_context_0014_helper_fn(_Atomic seL4_Word *counter)
742744
/* Try to recreate race situation of issue 633 */
743745
int test_smp_delete_sched_context(env_t env)
744746
{
745-
seL4_Error error;
746-
helper_thread_t helper;
747747
_Atomic seL4_Word counter = 0;
748748
seL4_Word prev_counter = counter;
749+
seL4_Error error;
750+
sel4utils_thread_t thread;
751+
sel4utils_thread_config_t config = thread_config_new(&env->simple);
752+
sched_params_t *p = &config.sched_params;
753+
seL4_Word core = CONFIG_MAX_NUM_NODES - 1;
754+
755+
config.no_ipc_buffer = true;
756+
config.custom_stack_size = true;
757+
config.stack_size = BIT(seL4_PageBits);
749758

750-
create_helper_thread(env, &helper);
751-
set_helper_priority(env, &helper, env->priority - 1);
752759
/* Run it on another core and time it such that it runs out of budget during the SC free */
753-
error = api_sched_ctrl_configure(simple_get_sched_ctrl(&env->simple, CONFIG_MAX_NUM_NODES - 1),
754-
helper.thread.sched_context.cptr, MIN_BUDGET_US, 10 * US_IN_MS, 0, 0);
755-
test_eq(error, seL4_NoError);
760+
*p = sched_params_periodic(*p, &env->simple, core, 10 * US_IN_MS, MIN_BUDGET_US, 0, 0);
756761

757-
start_helper(env, &helper, (helper_fn_t)sched_context_0014_helper_fn, (seL4_Word)&counter, 0, 0, 0);
762+
error = sel4utils_configure_thread_config(&env->vka, &env->vspace, &env->vspace, config, &thread);
763+
assert(error == 0);
764+
765+
/* Don't use start_helper, we want to run the helper function directly: */
766+
error = sel4utils_start_thread(&thread, sched_context_0014_helper_fn, &counter, NULL, 1);
767+
test_eq(error, seL4_NoError);
758768

759769
/* Wait till helper runs */
760770
while (counter == prev_counter);
761771

762-
vka_free_object(&env->vka, &helper.thread.sched_context);
772+
vka_free_object(&env->vka, &thread.sched_context);
763773

764774
return sel4test_get_result();
765775
}

0 commit comments

Comments
 (0)