summaryrefslogtreecommitdiff
path: root/src/user/app
diff options
context:
space:
mode:
authordzwdz2022-08-20 00:00:52 +0200
committerdzwdz2022-08-20 00:00:52 +0200
commit2a16c1f6f9118e7127d532421ae19b959b3f1d87 (patch)
treea1b5134cc4a460e38e02e4bb2103a7c06d255198 /src/user/app
parent040bb34290c9a4305e13637e002060411e5a8385 (diff)
user/libc: don't access the old stack from the new thread at all
Diffstat (limited to 'src/user/app')
-rw-r--r--src/user/app/tests/kernel/threads.c12
1 files changed, 11 insertions, 1 deletions
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);
}