6/21 PintOS Project3(5)

JK·2023년 6월 21일

PintOS Project3(5)

오늘은 종일 디버깅했습니다...

틀렸던 부분이 신경을 많이 안 썼던 부분이라 기분이 묘합니다

page_fault

userprog > exception.c

static void
page_fault (struct intr_frame *f) {
	bool not_present;  /* True: not-present page, false: writing r/o page. */
	bool write;        /* True: access was write, false: access was read. */
	bool user;         /* True: access by user, false: access by kernel. */
	void *fault_addr;  /* Fault address. */

	/* Obtain faulting address, the virtual address that was
	   accessed to cause the fault.  It may point to code or to
	   data.  It is not necessarily the address of the instruction
	   that caused the fault (that's f->rip). */

	fault_addr = (void *) rcr2();

	/* Turn interrupts back on (they were only off so that we could
	   be assured of reading CR2 before it changed). */
	intr_enable ();


	/* Determine cause. */
	not_present = (f->error_code & PF_P) == 0;
	write = (f->error_code & PF_W) != 0;
	user = (f->error_code & PF_U) != 0;

	
#ifdef VM
	/* For project 3 and later. */
	if (vm_try_handle_fault (f, fault_addr, user, write, not_present))
		return;
#endif

	exit(-1);

위의 함수에서 exit(-1); 이 처음에는 #ifdef 위에 있었는데 예상하기로는 page fault가 발생했을 때 VM으로 넘어가야 하는데 그 전에 exit(-1)에 걸려서 강제 종료가 되어 테스트에 실패한 것으로 예상합니다

그래서 exit(-1); 을 #end if 아랫부분으로 옮겨주니 테스트를 잘 통과하는 것을 확인했습니다

사실 더 고친 부분이 있기는 한데 exit(-1); 을 고친 부분이 너무 강렬해서 기억이 잘 나질 않습니다...
나중에 기억이 난다면 다시 올리겠습니다 :)

현재 진행 상황입니다
내일부터는 Stack Growth 부분을 구현할 예정입니다
중간에 어려운 부분을 블로그를 조금 참조했더니 제가 예상하지 못한 부분이 pass 되는 게 있어서 다시 공부하면서 왜 pass가 되었는지 알아보겠습니다

profile
^^

0개의 댓글