Per-thread state Notes: - Box::new(Thread { .. }) first constructs a new Thread on the stack, then moves it onto the heap. Fixed sized arrays therefore can't be used for the new process' stack because they overflow the current stack.
| 117 | /// therefore can't be used for the new process' stack because they |
| 118 | /// overflow the current stack. |
| 119 | pub struct Thread { |
| 120 | /// Thread ID |
| 121 | tid: u64, |
| 122 | |
| 123 | /// Process shared data |
| 124 | process: Arc<RwLock<Process>>, |
| 125 | |
| 126 | /// Page table physical address |
| 127 | /// |
| 128 | /// Note: Functions which manipulate page tables may temporarily |
| 129 | /// modify their page table. To avoid having to disable |
| 130 | /// interrupts, each thread's page table is saved and restored |
| 131 | /// during context switches |
| 132 | page_table_physaddr: u64, |
| 133 | |
| 134 | /// Kernel stack needed to handle system calls |
| 135 | /// and interrupts including |
| 136 | /// save/restore process state in context switch |
| 137 | kernel_stack: Vec<u8>, |
| 138 | |
| 139 | /// Address of the end of the stack. |
| 140 | /// This value is put in the Interrupt Stack Table |
| 141 | kernel_stack_end: u64, |
| 142 | |
| 143 | /// Address of the end of the user stack |
| 144 | user_stack_end: u64, |
| 145 | |
| 146 | /// Address within the kernel_stack which stores |
| 147 | /// the Context structure containing thread state. |
| 148 | context: u64, |
| 149 | } |
| 150 | |
| 151 | impl Thread { |
| 152 | /// Get the Thread ID |
nothing calls this directly
no outgoing calls
no test coverage detected