You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
staticbooluninit_initialize (structpage*page, void*kva) {
structuninit_page*uninit=&page->uninit;
/* Fetch first, page_initialize may overwrite the values */vm_initializer*init=uninit->init;
void*aux=uninit->aux;
/* TODO: You may need to fix this function. */returnuninit->page_initializer (page, uninit->type, kva) &&
(init ? init (page, aux) : true);
}
처음 vm_alloc_page_with_initializer를 호출하면 page의 type별로 uninit->page_initializer에 anon_initializer 또는 file_backed_initializer가 연결이 된다.
이 후 page_fault가 나면 위의 함수 uninit_initialize가 호출되는데 return을 보면 page_initializer에서 true를 반환해야 init에 등록된 lazy_segment가 실행될 수 있다.
하지만 아래의 type별 initializer를 보면 return 값이 없음에도 lazy_segment는 호출이 된다.
이 경우 page_initializer에서 true를 반환했을 것이다.
boolanon_initializer (structpage*page, enumvm_typetype, void*kva) {
/* Set up the handler */page->operations=&anon_ops;
structanon_page*anon_page=&page->anon;
structfile_segment*file_segment= (structfile_segment*)page->uninit.aux;
anon_page->occupy_sector_num=-1;
anon_page->file_segment=file_segment;
}
boolfile_backed_initializer (structpage*page, enumvm_typetype, void*kva) {
/* Set up the handler */page->operations=&file_ops;
structfile_page*file_page=&page->file;
structfile_segment*file_segment= (structfile_segment*)page->uninit.aux;
file_page->file_segment=file_segment;
}
위처럼 bool type을 반환하는 함수에서 return 값이 없더라도 true를 반환하는구나 생각을 가지고, 아래의 함수를 구현했다.
처음에는 return 값이 아예 없었고, 오류가 발생했다.
이 후 return true를 추가하고 정상 작동을 확인하였다.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
처음 vm_alloc_page_with_initializer를 호출하면 page의 type별로 uninit->page_initializer에 anon_initializer 또는 file_backed_initializer가 연결이 된다.
이 후 page_fault가 나면 위의 함수 uninit_initialize가 호출되는데 return을 보면 page_initializer에서 true를 반환해야 init에 등록된 lazy_segment가 실행될 수 있다.
하지만 아래의 type별 initializer를 보면 return 값이 없음에도 lazy_segment는 호출이 된다.
이 경우 page_initializer에서 true를 반환했을 것이다.
위처럼 bool type을 반환하는 함수에서 return 값이 없더라도 true를 반환하는구나 생각을 가지고, 아래의 함수를 구현했다.
처음에는 return 값이 아예 없었고, 오류가 발생했다.
이 후 return true를 추가하고 정상 작동을 확인하였다.
결론
anon_initializer, file_backed_initializer는 return이 없어도 true를 반환하여 init이 실행되는데
-> return uninit->page_initializer (page, uninit->type, kva) && (init ? init (page, aux) : true);
swap_in 같은 경우에는 왜 return true를 명시해야만 돌아가는가?
Beta Was this translation helpful? Give feedback.
All reactions