미소를뿌리는감자의 코딩
[Pintos_project3 (5)] anon_initializer 본문
728x90
1. 개요
anon_initializer은 UNINIT으로 초기화 되어 있는 페이지 관련 설정을 anon과 관련된 설정으로 바꾸어주는 함수라고 할 수 있다.
따로, 추가적으로 이야기할 부분이 없어 바로 본문으로 넘어가려 한다.
2. 본문
// vm/anon.c
/* Initialize the file mapping */
bool
anon_initializer (struct page *page, enum vm_type type, void *kva) { // kva; kernel virtual address
/* Set up the handler */
/* <Pseudo>
* 페이지가 지금 UNINIT으로 설정되어 있으니까, 이를 페이지 type에 따라서 다르게 설정해 줌. */
struct uninit_page *uninit = &page->uninit; // page의 union중 하나에서 설정되어 있는 uninit을 가지고 옴.
memset(uninit, 0, sizeof(struct uninit_page)); // vm에서 페이지를 차지하고 있는 대상 uninit page에 대해서 0으로 초기화.
page->operations = &anon_ops; // uninit과 관련된 operations에서 anon_ops operation을 설정해 줌.
struct anon_page *anon_page = &page->anon;// page union에서 UNINIT이 아니라, anon을 가리키도록 설정.
return true;
}
uninit이 할당되어 있는 페이지를 0으로 초기화 해주고, 해당 페이지 operation을 anon과 관련된 operation으로 바꾸어 준다.
3. 결과
아직도 이전과 동일하게 123 of 141 tests failed를 나타낸다.

728x90
'정글 일지' 카테고리의 다른 글
[Pintos_project3 (7)] setup_stack (0) | 2024.11.30 |
---|---|
[Pintos_project3 (6)] load_segment & lazy_load_segment (0) | 2024.11.30 |
[Pintos_project3 (4)] vm_alloc_page_with_initializer (0) | 2024.11.30 |
[Pintos_project3 (3)] spt_insert_page (0) | 2024.11.29 |
[Pintos_project3 (2)] spt_find_page (0) | 2024.11.29 |