diff options
author | sotech117 <michael_foiani@brown.edu> | 2024-02-20 19:49:59 +0000 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2024-02-20 19:49:59 +0000 |
commit | 9c90e73fda0d5df2e1f11b32d459d3bb07a63192 (patch) | |
tree | 29272e6765eca78d6a5a9a7c23ec435eaa138d64 /kernel/test | |
parent | d0c413bd585e5dc1ee2fc2bc8b4af110ef5900c6 (diff) |
small conceptual issue with retvals when threads are cancelled. will ask
Diffstat (limited to 'kernel/test')
-rw-r--r-- | kernel/test/proctest.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/kernel/test/proctest.c b/kernel/test/proctest.c index f49da72..ab69512 100644 --- a/kernel/test/proctest.c +++ b/kernel/test/proctest.c @@ -277,10 +277,17 @@ void test_out_of_order_termination() /* Test threads' cancellation fields. */ +void *did_run_func(long arg1, void *arg2) +{ + // arg2 is a boolean flag that indicated this ran + *(int *)arg2 = 1; + return NULL; +} void test_cancellation() { proc_t *new_proc1 = proc_create("proc test 1"); - kthread_t *new_kthread1 = kthread_create(new_proc1, test_func, new_proc1->p_pid, new_proc1); + int did_run = 0; + kthread_t *new_kthread1 = kthread_create(new_proc1, did_run_func, new_proc1->p_pid, (void *)&did_run); test_assert(new_kthread1->kt_cancelled == 0, "Thread should not be cancelled"); sched_make_runnable(new_kthread1); @@ -293,6 +300,7 @@ void test_cancellation() int ret = do_waitpid(new_proc1->p_pid, &status, 0); test_assert(ret != -ECHILD, "Should have found the process"); test_assert(status == 1, "Returned status not set correctly"); + test_assert(did_run == 0, "Thread should not have run if it was cancelled"); } |