
현재 PintOS 에는 가상 주소와 물리주소 매핑하는 (하드웨어) 페이지 테이블(pml4) 이 존재
pml4는 현재 물리메모리에 올라온 것만 관리 가능
이 하드웨어 페이지 테이블인 (pml4)를 보조하기 위한 추가적인 페이지 테이블이 필요
메모리에 올라오려고 하는 예정된 것들 등등을 담는 SPT
구현 위치 : vm/vm.c
void supplemental_page_table_init (struct supplemental_page_table *spt);
해시, 배열, 비트맵…userprog/process.c의 initd 함수 내부) ⇒ifdef 로 구현userprog/process.c의 __do_fork 함수 내부) ⇒ ifdef 로 구현struct page *spt_find_page (struct supplemental_page_table *spt, void *va);
Return valuebool spt_insert_page (struct supplemental_page_table *spt, struct page *page);
Return Value우리 조는 해시함수 자료구조를 사용하기로 했고
struct page
{
const struct page_operations *operations;
void *va; /* Address in terms of user space */
struct frame *frame; /* Back reference for frame */
/* Hash 자료구조 활용 위한 멤버변수 추가 */
struct hash_elem hash_elem; /* Hash table element. */
void *addr; /* Virtual address. */
/* Per-type data are binded into the union.
* Each function automatically detects the current union */
union
{
struct uninit_page uninit;
struct anon_page anon;
struct file_page file;
#ifdef EFILESYS
struct page_cache page_cache;
#endif
};
};
#include "lib/kernel/hash.h" // 해시 함수 자료구조 활용 위한 import
struct supplemental_page_table
{
struct hash pages;
};
/* Initialize new supplemental page table */
void supplemental_page_table_init(struct supplemental_page_table *spt UNUSED)
{
// 인자로 받은 spt의 pages 해시 테이블을 초기화
hash_init(&spt->pages, page_hash, page_less, NULL);
}
위와같이 SPT 정의와 SPT 초기화 함수를 구현했다.
해시함수로 구현하는 방법 어떻게 해야하나 고민했는데
APPENDIX에 있더라...