| 190 | } |
| 191 | |
| 192 | TaskControlBlock::~TaskControlBlock() { |
| 193 | // 从线程组中移除 |
| 194 | LeaveThreadGroup(); |
| 195 | |
| 196 | // 释放内核栈 |
| 197 | if (kernel_stack) { |
| 198 | aligned_free(kernel_stack); |
| 199 | kernel_stack = nullptr; |
| 200 | } |
| 201 | |
| 202 | // 释放页表(如果有用户空间页表) |
| 203 | if (page_table) { |
| 204 | // 如果是私有页表(非共享),需要释放物理页 |
| 205 | auto should_free_pages = !(aux->clone_flags & clone_flag::kVm); |
| 206 | VirtualMemorySingleton::instance().DestroyPageDirectory(page_table, |
| 207 | should_free_pages); |
| 208 | page_table = nullptr; |
| 209 | } |
| 210 | |
| 211 | // 释放辅助数据 |
| 212 | if (aux) { |
| 213 | delete aux; |
| 214 | aux = nullptr; |
| 215 | } |
| 216 | } |
nothing calls this directly
no test coverage detected