Skip to content

Commit

Permalink
Merge pull request #230 from lewiszlw/patch-14
Browse files Browse the repository at this point in the history
Update ch8 1thread.rst
  • Loading branch information
wyfcyx authored Oct 27, 2024
2 parents 0e2a30f + 8fa49e1 commit 00b7877
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions source/chapter8/1thread.rst
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
available.ctx.x1 = guard as u64; //ctx.x1 is old return address
available.ctx.nx1 = f as u64; //ctx.nx1 is new return address
available.ctx.x2 = s_ptr.offset(32) as u64; //cxt.x2 is sp
available.ctx.x2 = s_ptr.offset(-32) as u64; //cxt.x2 is sp
}
available.state = State::Ready;
Expand Down Expand Up @@ -327,7 +327,7 @@
#[inline(never)]
unsafe fn switch(old: *mut TaskContext, new: *const TaskContext) {
// a0: old, a1: new
llvm_asm!("
asm!("
//if comment below lines: sd x1..., ld x1..., TASK2 can not finish, and will segment fault
sd x1, 0x00(a0)
sd x2, 0x08(a0)
Expand All @@ -348,8 +348,8 @@
ld t0, 0x70(a1)
jr t0
"
: : : : "volatile", "alignstack"
",
options(noreturn)
);
}
Expand Down Expand Up @@ -388,4 +388,4 @@

.. [#explain_green_thread] https://cfsamson.gitbook.io/green-threads-explained-in-200-lines-of-rust/
.. [#code_green_thread] https://github.com/cfsamson/example-greenthreads
.. [#code_green_thread] https://github.com/cfsamson/example-greenthreads

0 comments on commit 00b7877

Please sign in to comment.