정글 일지
[Pintos_project3 (5)] anon_initializer
미뿌감
2024. 11. 30. 12:52
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