summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanjit Bhat <[email protected]>2023-10-03 15:42:07 -0500
committerSanjit Bhat <[email protected]>2023-10-03 15:42:07 -0500
commitb43a5b2b12d20ec0aa8de26dd273558b9bc4522b (patch)
treef71509ae632838b8301b666bd8810d7536843b18
parent9723a5f06fc2376bf3a2a8f2615557b0f7c47dcc (diff)
downloadxv6-labs-b43a5b2b12d20ec0aa8de26dd273558b9bc4522b.tar.gz
xv6-labs-b43a5b2b12d20ec0aa8de26dd273558b9bc4522b.tar.bz2
xv6-labs-b43a5b2b12d20ec0aa8de26dd273558b9bc4522b.zip
thread0 state free upon completion
-rw-r--r--user/uthread.c7
1 files 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);
}