미소를뿌리는감자의 코딩
[Pintos_project3 (11)] vm_try_handle_fault 본문
728x90
1. 개요
page fault가 발생했을 때의 handler인 vm_try_handle_fault에 대해서 알아보자.
2. 본문
/** Project 3: Memory Management - Return true on success */
bool vm_try_handle_fault(struct intr_frame *f UNUSED, void *addr UNUSED, bool user UNUSED, bool write UNUSED, bool not_present UNUSED) {
struct supplemental_page_table *spt UNUSED = &thread_current()->spt;
struct page *page = spt_find_page(&thread_current()->spt, addr);
/* TODO: Validate the fault */
if (addr == NULL || is_kernel_vaddr(addr))
return false;
return vm_do_claim_page(page); // demand page 수행
}
이번 코드는 정말 간단하다.
현재 thread의 spt를 찾아주고, spt를 바탕으로 va에 해당하는 page를 찾아준다.
이후, 찾은 page를 기반으로 vm_do_claim()함수를 이용해서 VM와 PM을 mapping 시켜준다.
3. 결과
56 of 141 tests failed를 확인할 수 있다.

728x90
'정글 일지' 카테고리의 다른 글
[Pintos_project3 (13)] uninit_destory, anon_destory (0) | 2024.12.02 |
---|---|
[Pintos_project3 (12)] supplemental_page_table_copy, supplemental_page_table_kill (0) | 2024.12.02 |
[Pintos_project3 (10)] vm_anon_init, setup_stack (0) | 2024.12.02 |
[Pintos_project3 (9)] vm_claim_page, vm_do_claim_page (0) | 2024.12.02 |
[Pintos_project3 (8)] vm_get_frame, vm_evict_frame, vm_get_victim (0) | 2024.11.30 |