From b43a5b2b12d20ec0aa8de26dd273558b9bc4522b Mon Sep 17 00:00:00 2001 From: Sanjit Bhat Date: Tue, 3 Oct 2023 15:42:07 -0500 Subject: thread0 state free upon completion --- user/uthread.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/user/uthread.c b/user/uthread.c index 06349f5..18b773d 100644 --- a/user/uthread.c +++ b/user/uthread.c @@ -23,10 +23,8 @@ void thread_init(void) { // main() is thread 0, which will make the first invocation to - // thread_schedule(). it needs a stack so that the first thread_switch() can - // save thread 0's state. thread_schedule() won't run the main thread ever - // again, because its state is set to RUNNING, and thread_schedule() selects - // a RUNNABLE thread. + // thread_schedule(). It needs a stack so that the first thread_switch() can + // save thread 0's state. current_thread = &all_thread[0]; current_thread->state = RUNNING; } @@ -157,6 +155,7 @@ main(int argc, char *argv[]) thread_create(thread_a); thread_create(thread_b); thread_create(thread_c); + current_thread->state = FREE; thread_schedule(); exit(0); } -- cgit v1.2.3