mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-24 18:36:24 +04:00
Using Self in some methods of mm/task; maintain base_size when exec
This commit is contained in:
parent
1cc69229d3
commit
995387bfba
@ -233,7 +233,7 @@ impl MemorySet {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
///Clone a same `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();
|
let mut memory_set = Self::new_bare();
|
||||||
// map trampoline
|
// map trampoline
|
||||||
memory_set.map_trampoline();
|
memory_set.map_trampoline();
|
||||||
@ -294,7 +294,7 @@ impl MapArea {
|
|||||||
map_perm,
|
map_perm,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn from_another(another: &MapArea) -> Self {
|
pub fn from_another(another: &Self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
vpn_range: VPNRange::new(another.vpn_range.get_start(), another.vpn_range.get_end()),
|
vpn_range: VPNRange::new(another.vpn_range.get_start(), another.vpn_range.get_end()),
|
||||||
data_frames: BTreeMap::new(),
|
data_frames: BTreeMap::new(),
|
||||||
|
@ -105,6 +105,8 @@ impl TaskControlBlock {
|
|||||||
inner.memory_set = memory_set;
|
inner.memory_set = memory_set;
|
||||||
// update trap_cx ppn
|
// update trap_cx ppn
|
||||||
inner.trap_cx_ppn = trap_cx_ppn;
|
inner.trap_cx_ppn = trap_cx_ppn;
|
||||||
|
// initialize base_size
|
||||||
|
inner.base_size = user_sp;
|
||||||
// initialize trap_cx
|
// initialize trap_cx
|
||||||
let trap_cx = inner.get_trap_cx();
|
let trap_cx = inner.get_trap_cx();
|
||||||
*trap_cx = TrapContext::app_init_context(
|
*trap_cx = TrapContext::app_init_context(
|
||||||
@ -116,7 +118,7 @@ impl TaskControlBlock {
|
|||||||
);
|
);
|
||||||
// **** release inner automatically
|
// **** release inner automatically
|
||||||
}
|
}
|
||||||
pub fn fork(self: &Arc<TaskControlBlock>) -> Arc<TaskControlBlock> {
|
pub fn fork(self: &Arc<Self>) -> Arc<Self> {
|
||||||
// ---- access parent PCB exclusively
|
// ---- access parent PCB exclusively
|
||||||
let mut parent_inner = self.inner_exclusive_access();
|
let mut parent_inner = self.inner_exclusive_access();
|
||||||
// copy user space(include trap context)
|
// copy user space(include trap context)
|
||||||
|
Loading…
Reference in New Issue
Block a user