Skip to content

Commit

Permalink
Using Self in some methods of mm/task; maintain base_size when exec
Browse files Browse the repository at this point in the history
  • Loading branch information
wyfcyx committed Jul 19, 2022
1 parent 1cc6922 commit 995387b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions os/src/mm/memory_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl MemorySet {
)
}
///Clone a same `MemorySet`
pub fn from_existed_user(user_space: &MemorySet) -> MemorySet {
pub fn from_existed_user(user_space: &Self) -> Self {
let mut memory_set = Self::new_bare();
// map trampoline
memory_set.map_trampoline();
Expand Down Expand Up @@ -294,7 +294,7 @@ impl MapArea {
map_perm,
}
}
pub fn from_another(another: &MapArea) -> Self {
pub fn from_another(another: &Self) -> Self {
Self {
vpn_range: VPNRange::new(another.vpn_range.get_start(), another.vpn_range.get_end()),
data_frames: BTreeMap::new(),
Expand Down
4 changes: 3 additions & 1 deletion os/src/task/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ impl TaskControlBlock {
inner.memory_set = memory_set;
// update trap_cx ppn
inner.trap_cx_ppn = trap_cx_ppn;
// initialize base_size
inner.base_size = user_sp;
// initialize trap_cx
let trap_cx = inner.get_trap_cx();
*trap_cx = TrapContext::app_init_context(
Expand All @@ -116,7 +118,7 @@ impl TaskControlBlock {
);
// **** release inner automatically
}
pub fn fork(self: &Arc<TaskControlBlock>) -> Arc<TaskControlBlock> {
pub fn fork(self: &Arc<Self>) -> Arc<Self> {
// ---- access parent PCB exclusively
let mut parent_inner = self.inner_exclusive_access();
// copy user space(include trap context)
Expand Down

0 comments on commit 995387b

Please sign in to comment.