Avoid poorly chosen variable names

This commit is contained in:
Ruihan Li
2024-05-14 01:10:24 +08:00
committed by Tate, Hongliang Tian
parent a215cb54d9
commit 47fe10f17b
2 changed files with 10 additions and 10 deletions

View File

@ -99,14 +99,14 @@ fn switch_to_task(next_task: Arc<Task>) {
Some(current_task) => {
let cx_ptr = current_task.ctx().get();
let mut task = current_task.inner_exclusive_access();
let mut task_inner = current_task.inner_exclusive_access();
debug_assert_ne!(task.task_status, TaskStatus::Sleeping);
if task.task_status == TaskStatus::Runnable {
drop(task);
debug_assert_ne!(task_inner.task_status, TaskStatus::Sleeping);
if task_inner.task_status == TaskStatus::Runnable {
drop(task_inner);
GLOBAL_SCHEDULER.lock_irq_disabled().enqueue(current_task);
} else if task.task_status == TaskStatus::Sleepy {
task.task_status = TaskStatus::Sleeping;
} else if task_inner.task_status == TaskStatus::Sleepy {
task_inner.task_status = TaskStatus::Sleeping;
}
cx_ptr

View File

@ -278,7 +278,7 @@ impl TaskOptions {
current_task.exit();
}
let mut result = Task {
let mut new_task = Task {
func: self.func.unwrap(),
data: self.data.unwrap(),
user_space: self.user_space,
@ -292,7 +292,7 @@ impl TaskOptions {
cpu_affinity: self.cpu_affinity,
};
let ctx = result.ctx.get_mut();
let ctx = new_task.ctx.get_mut();
ctx.rip = kernel_task_entry as usize;
// We should reserve space for the return address in the stack, otherwise
// we will write across the page boundary due to the implementation of
@ -302,9 +302,9 @@ impl TaskOptions {
// to at least 16 bytes. And a larger alignment is needed if larger arguments
// are passed to the function. The `kernel_task_entry` function does not
// have any arguments, so we only need to align the stack pointer to 16 bytes.
ctx.regs.rsp = (crate::vm::paddr_to_vaddr(result.kstack.end_paddr() - 16)) as u64;
ctx.regs.rsp = (crate::vm::paddr_to_vaddr(new_task.kstack.end_paddr() - 16)) as u64;
Ok(Arc::new(result))
Ok(Arc::new(new_task))
}
/// Build a new task and run it immediately.