From 2a16c1f6f9118e7127d532421ae19b959b3f1d87 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 20 Aug 2022 00:00:52 +0200 Subject: user/libc: don't access the old stack from the new thread at all --- src/user/app/tests/kernel/threads.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/user/app/tests/kernel/threads.c') diff --git a/src/user/app/tests/kernel/threads.c b/src/user/app/tests/kernel/threads.c index 2964883..cb7111d 100644 --- a/src/user/app/tests/kernel/threads.c +++ b/src/user/app/tests/kernel/threads.c @@ -18,7 +18,6 @@ static void test_basic_thread(void) { test(global_n == 10); } - handle_t global_h; static void shared_handle(void *sem) { handle_t ends[2]; @@ -39,7 +38,18 @@ static void test_shared_handle(void) { test(!strcmp("Hello!", buf)); } +static void many_thread(void *arg) { + *(uint64_t*)arg += 10; +} +static void test_many_threads(void) { + uint64_t n = 0; + for (int i = 0; i < 10; i++) thread_create(0, many_thread, &n); + for (int i = 0; i < 10; i++) _syscall_await(); + test(n == 100); +} + void r_k_threads(void) { run_test(test_basic_thread); run_test(test_shared_handle); + run_test(test_many_threads); } -- cgit v1.2.3