Skip to content

Commit

Permalink
修订paging
Browse files Browse the repository at this point in the history
  • Loading branch information
min0911Y committed Jan 2, 2025
1 parent 382b538 commit fcdb052
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/kernel/mm/vpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ void page_link_addr_pde(usize addr, usize pd, usize map_addr) {
// COW
// 这里不需要大于1,因为我们就相当于是抛弃了原来的页
if (pages[physics->addr].count && physics->user) pages[physics->addr].count--;
pages[PIDX(map_addr)].count++;
physics->addr = PIDX(map_addr);
physics->wrable = true;
physics->user = true;
Expand Down Expand Up @@ -301,7 +302,7 @@ void page_unlink_pd(usize addr, usize pd) {
}

var pte = pteof(addr, pde->addr << 12);
if (pages[pte->addr].count > 1) pages[pte->addr].count--;
if (pages[pte->addr].count && pte->user) pages[pte->addr].count--;
pte->present = false;
flush_tlb((u32)pde);
flush_tlb(addr);
Expand Down

0 comments on commit fcdb052

Please sign in to comment.