From 43f023e0b0a2892c9190a854ecf012614b4047d0 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Thu, 4 May 2023 22:19:00 +0200 Subject: [PATCH] Fix join not working on join.c --- src/main.rs | 2 +- test/syscall_tests/join.c | 34 ++++++++++++---------------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/main.rs b/src/main.rs index eea6649..a481d44 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,7 +34,7 @@ struct Args { /// 1 to enable machine debug, /// 2 to enable system debug, /// 3 to enable all debug - #[arg(short, long, value_parser = clap::value_parser!(u8).range(0..=3))] + #[arg(short, long, value_parser = clap::value_parser!(u8).range(0..=3), default_value_t = 0)] debug: u8, /// Path to the executable binary file to execute #[arg(short = 'x', long, value_name = "PATH")] diff --git a/test/syscall_tests/join.c b/test/syscall_tests/join.c index 8d26596..2466066 100644 --- a/test/syscall_tests/join.c +++ b/test/syscall_tests/join.c @@ -1,36 +1,26 @@ #include "userlib/syscall.h" #include "userlib/libnachos.h" - -const int N = 3; -int iplein = 0; -int ivide = 0; -int tab[3]; -SemId svide; -SemId splein; - -void th1(); - -void th2(); - -int main() { - ThreadId th1 = threadCreate("th1", th1); - ThreadId th2 = threadCreate("th2", th2); - Join(th1); - Join(th2); - return 0; -} - -void th1() { +void thread1() { for(int i = 0; i < 10; i++) { n_printf("Hello from th1\n"); } } -void th2() { +void thread2() { for(int i = 0; i < 10; i++) { n_printf("Hello from th2\n"); } } + + +int main() { + ThreadId th1 = threadCreate("thread 1", thread1); + ThreadId th2 = threadCreate("thread 2", thread2); + Join(th1); + Join(th2); + Shutdown(); + return 0; +}