Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ch8 1thread.rst #230

Merged
merged 3 commits into from
Oct 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading