MCPcopy Create free account
hub / github.com/chyyuu/os_kernel_lab / new

Method new

os/src/task/task.rs:50–72  ·  view source on GitHub ↗
(
        process: Arc<ProcessControlBlock>,
        ustack_base: usize,
        alloc_user_res: bool,
    )

Source from the content-addressed store, hash-verified

48
49impl TaskControlBlock {
50 pub fn new(
51 process: Arc<ProcessControlBlock>,
52 ustack_base: usize,
53 alloc_user_res: bool,
54 ) -> Self {
55 let res = TaskUserRes::new(Arc::clone(&process), ustack_base, alloc_user_res);
56 let trap_cx_ppn = res.trap_cx_ppn();
57 let kstack = kstack_alloc();
58 let kstack_top = kstack.get_top();
59 Self {
60 process: Arc::downgrade(&process),
61 kstack,
62 inner: unsafe {
63 UPIntrFreeCell::new(TaskControlBlockInner {
64 res: Some(res),
65 trap_cx_ppn,
66 task_cx: TaskContext::goto_trap_return(kstack_top),
67 task_status: TaskStatus::Ready,
68 exit_code: None,
69 })
70 },
71 }
72 }
73}
74
75#[derive(Copy, Clone, PartialEq)]

Callers

nothing calls this directly

Calls 4

cloneFunction · 0.85
kstack_allocFunction · 0.85
trap_cx_ppnMethod · 0.80
get_topMethod · 0.80

Tested by

no test coverage detected