|
@ -69,7 +69,25 @@ _fifo_swap_out_victim(struct mm_struct *mm, struct Page ** ptr_page, int in_tick |
|
|
//(1) unlink the earliest arrival page in front of pra_list_head qeueue |
|
|
//(1) unlink the earliest arrival page in front of pra_list_head qeueue |
|
|
//(2) set the addr of addr of this page to ptr_page |
|
|
//(2) set the addr of addr of this page to ptr_page |
|
|
/* Select the tail */ |
|
|
/* Select the tail */ |
|
|
list_entry_t *le = head->prev; |
|
|
|
|
|
|
|
|
// 从后往前,最后面的是最早访问的 |
|
|
|
|
|
list_entry_t *current = head->prev; |
|
|
|
|
|
list_entry_t *le = NULL; |
|
|
|
|
|
for (; current != head; current = current->prev) { |
|
|
|
|
|
pte_t *ptep = get_pte(mm->pgdir, le2vma(current, vm_start), 0); |
|
|
|
|
|
cprintf("@@@ %d %x :a page\n", *ptep & PTE_A, current); |
|
|
|
|
|
if (*ptep & PTE_A) { // 访问位为1 |
|
|
|
|
|
*ptep &= !PTE_A; // 清除访问位 |
|
|
|
|
|
list_del(current); // 从链表中移除 |
|
|
|
|
|
list_add(head, current); // 添加到链表头部 |
|
|
|
|
|
cprintf("### %d %x :clear access\n", *ptep & PTE_A, current); |
|
|
|
|
|
} else { |
|
|
|
|
|
le = current; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (le == NULL) { |
|
|
|
|
|
le = head->prev; // 循环一遍找不到就最后一个 |
|
|
|
|
|
} |
|
|
assert(head!=le); |
|
|
assert(head!=le); |
|
|
struct Page *p = le2page(le, pra_page_link); |
|
|
struct Page *p = le2page(le, pra_page_link); |
|
|
list_del(le); |
|
|
list_del(le); |
|
@ -97,26 +115,26 @@ _fifo_check_swap(void) { |
|
|
assert(pgfault_num==5); |
|
|
assert(pgfault_num==5); |
|
|
cprintf("write Virt Page b in fifo_check_swap\n"); |
|
|
cprintf("write Virt Page b in fifo_check_swap\n"); |
|
|
*(unsigned char *)0x2000 = 0x0b; |
|
|
*(unsigned char *)0x2000 = 0x0b; |
|
|
assert(pgfault_num==5); |
|
|
|
|
|
|
|
|
assert(pgfault_num==6); // 从这里开始缺页次数与FIFO不同了 |
|
|
cprintf("write Virt Page a in fifo_check_swap\n"); |
|
|
cprintf("write Virt Page a in fifo_check_swap\n"); |
|
|
*(unsigned char *)0x1000 = 0x0a; |
|
|
*(unsigned char *)0x1000 = 0x0a; |
|
|
assert(pgfault_num==6); |
|
|
assert(pgfault_num==6); |
|
|
cprintf("write Virt Page b in fifo_check_swap\n"); |
|
|
cprintf("write Virt Page b in fifo_check_swap\n"); |
|
|
*(unsigned char *)0x2000 = 0x0b; |
|
|
*(unsigned char *)0x2000 = 0x0b; |
|
|
assert(pgfault_num==7); |
|
|
|
|
|
|
|
|
assert(pgfault_num==6); |
|
|
cprintf("write Virt Page c in fifo_check_swap\n"); |
|
|
cprintf("write Virt Page c in fifo_check_swap\n"); |
|
|
*(unsigned char *)0x3000 = 0x0c; |
|
|
*(unsigned char *)0x3000 = 0x0c; |
|
|
assert(pgfault_num==8); |
|
|
|
|
|
|
|
|
assert(pgfault_num==7); |
|
|
cprintf("write Virt Page d in fifo_check_swap\n"); |
|
|
cprintf("write Virt Page d in fifo_check_swap\n"); |
|
|
*(unsigned char *)0x4000 = 0x0d; |
|
|
*(unsigned char *)0x4000 = 0x0d; |
|
|
assert(pgfault_num==9); |
|
|
|
|
|
|
|
|
assert(pgfault_num==8); |
|
|
cprintf("write Virt Page e in fifo_check_swap\n"); |
|
|
cprintf("write Virt Page e in fifo_check_swap\n"); |
|
|
*(unsigned char *)0x5000 = 0x0e; |
|
|
*(unsigned char *)0x5000 = 0x0e; |
|
|
assert(pgfault_num==10); |
|
|
|
|
|
|
|
|
assert(pgfault_num==8); |
|
|
cprintf("write Virt Page a in fifo_check_swap\n"); |
|
|
cprintf("write Virt Page a in fifo_check_swap\n"); |
|
|
assert(*(unsigned char *)0x1000 == 0x0a); |
|
|
assert(*(unsigned char *)0x1000 == 0x0a); |
|
|
*(unsigned char *)0x1000 = 0x0a; |
|
|
*(unsigned char *)0x1000 = 0x0a; |
|
|
assert(pgfault_num==11); |
|
|
|
|
|
|
|
|
assert(pgfault_num==9); |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|