From 87470490676ee6dc087e3ebe2a3ce3cfbd4afbd9 Mon Sep 17 00:00:00 2001 From: Sanjit Bhat Date: Wed, 13 Sep 2023 02:01:38 -0400 Subject: release lab thread --- user/uthread_switch.S | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 user/uthread_switch.S (limited to 'user/uthread_switch.S') diff --git a/user/uthread_switch.S b/user/uthread_switch.S new file mode 100644 index 0000000..5defb12 --- /dev/null +++ b/user/uthread_switch.S @@ -0,0 +1,11 @@ + .text + + /* + * save the old thread's registers, + * restore the new thread's registers. + */ + + .globl thread_switch +thread_switch: + /* YOUR CODE HERE */ + ret /* return to ra */ -- cgit v1.2.3 From edd523ffcb39c1c57944796fabfc71c70a10ce2e Mon Sep 17 00:00:00 2001 From: Mole Shang <135e2@135e2.dev> Date: Fri, 16 Feb 2024 11:29:36 +0800 Subject: lab thread: finish --- user/uthread_switch.S | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'user/uthread_switch.S') diff --git a/user/uthread_switch.S b/user/uthread_switch.S index 5defb12..19cc400 100644 --- a/user/uthread_switch.S +++ b/user/uthread_switch.S @@ -7,5 +7,33 @@ .globl thread_switch thread_switch: - /* YOUR CODE HERE */ + sd ra, 0(a0) + sd sp, 8(a0) + sd s0, 16(a0) + sd s1, 24(a0) + sd s2, 32(a0) + sd s3, 40(a0) + sd s4, 48(a0) + sd s5, 56(a0) + sd s6, 64(a0) + sd s7, 72(a0) + sd s8, 80(a0) + sd s9, 88(a0) + sd s10, 96(a0) + sd s11, 104(a0) + + ld ra, 0(a1) + ld sp, 8(a1) + ld s0, 16(a1) + ld s1, 24(a1) + ld s2, 32(a1) + ld s3, 40(a1) + ld s4, 48(a1) + ld s5, 56(a1) + ld s6, 64(a1) + ld s7, 72(a1) + ld s8, 80(a1) + ld s9, 88(a1) + ld s10, 96(a1) + ld s11, 104(a1) ret /* return to ra */ -- cgit v1.2.3