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

SCHED0021: decrease chances of a race condition #105

Merged
merged 1 commit into from
Oct 27, 2023
Merged
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
12 changes: 9 additions & 3 deletions apps/sel4test-tests/src/tests/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1598,19 +1598,25 @@ static int test_simple_preempt(struct env *env)

/* Set a timeout for the test.
* Each thread should be run for one tick */
uint64_t start = time_now(env);
uint64_t now = start;

/* Start executing other threads */
ZF_LOGD("Releasing Threads");
/* Release our time slice now to get a new one. That should ensure we are
* not interrupted due to bad luck by the preemptive scheduler right after
* setting test_simple_preempt_start to 1 and then voluntarily yielding
* (which gives the preemption threads 2 time slices instead of one). For
* the same reason we are also printing the ZF_LOGD() above already.
*/
seL4_Yield();
uint64_t start = time_now(env);
test_simple_preempt_start = 1;
/* Yield should cause all other threads to execute before returning
* to the current thread. */
seL4_Yield();
test_simple_preempt_start = 0;

/* Get the total time taken to synchronise */
now = time_now(env);
uint64_t now = time_now(env);
uint64_t duration = now - start;

for (size_t thread = 0; thread < PREEMPTION_THREADS; thread += 1) {
Expand Down