jun-wiki

View My GitHub Profile

Posts (Latest 10 updated) :
Read all

오늘은 저번 구현에 이어서 보조 페이지 테이블 복사와 정리 함수를 구현했다

uninit과 anon에 따라 다르게 destoy 해줘야 해서 이거부터 해결했다

anon.c

static void
anon_destroy (struct page *page) {
  struct anon_page *ap = &page->anon;
  // 프레임 반납
  if (page->frame) {
    struct thread *cur = thread_current();
    page->frame->page = NULL;
    vm_free_frame(page->frame);
    page->frame = NULL;
  }
}

프레임 잘 썼으니 반납해주면 된다

메모리 해제는 호출자가 해줄거다


uninit.c

static void
uninit_destroy (struct page *page) {
	struct uninit_page *uninit UNUSED = &page->uninit;
	if (uninit->aux) {
		free(uninit->aux);
		uninit->aux = NULL;
	}
}

그냥 aux 해제해주면 끝이다


vm.c ```c /* 콜백 함수 */ static void page_free_action(struct hash_elem *e, void *aux) { struct page *p = hash_entry(e, struct page, spt_elem); destroy(p); free(p); }

/* Free the resource hold by the supplemental page table / / 보조 페이지 테이블이 보유한 리소스를 해제한다. */ void supplemental_page_table_kill(struct supplemental_page_table *spt) { hash_destroy(&spt->h, page_free_action); } ```

spt 리소스 해제하는 함수인데 콜백함수를 통해 구현했다



딴 거 뭐 구현해도 돌아가지도 않고 뭐 해야 할지도 몰라서 다 못했다

그리고 이번 프로젝트는 팀 협력이라서 깃 쓰는 법이나 설정 보느라 시간도 많이 써버림 ㅇㅇ