PintOS 2주차 - day3

솔다·2022년 12월 25일
0

알고리즘 풀고 CS책을 읽다가 둘째날에 회고록을 적는걸 잊었다...
시작하자마자 하루가 빠진게 너무 아쉽지만 그래도 이제는 빠지지 않고 적어보고자 한다.

오늘도 첫째날과 비교해도 딱히 진도가 많이 나가지는 않았다.

코드에 대해서 이해하고, 과제를 차근차근 진행하려고 했는데 여전히 argument들을 유저 stack에 쌓는 과정을 구현하지 못하고 있다.

과제를 진행하면서 우리가 가동할 프로그램이 Userstack을 참조해서 가동될 수 있게 하도록 hex_dump()함수를 추가했지만, 기본적으로 PintOS에서 적절하게 해볼 테스트가 없어서 난관을 마주했다.

/* Switch the current execution context to the f_name.
 * Returns -1 on fail. */
int
process_exec (void *f_name) {
	char *file_name = f_name;
	bool success;
	char *token, *save_ptr;

	/* We cannot use the intr_frame in the thread structure.
	 * This is because when current thread rescheduled,
	 * it stores the execution information to the member. */
	struct intr_frame _if;
	_if.ds = _if.es = _if.ss = SEL_UDSEG;
	_if.cs = SEL_UCSEG;
	_if.eflags = FLAG_IF | FLAG_MBS;

	/* We first kill the current context */
	process_cleanup ();

	/*first, parse the file_name, There's still arguements in file_name*/
	token= strtok_r(file_name, " ", &save_ptr);

	/* And then load the binary */
	success = load (token, &_if);

	/* If load failed, quit. */
	palloc_free_page (file_name);
	if (!success)
		return -1;

	// argument_stack(token, count, &_if.rsp);
	hex_dump(_if.rsp, _if.rsp, LOADER_PHYS_BASE - _if.rsp, true);

	/* Start switched process. */
	do_iret (&_if);
	NOT_REACHED ();
}

인자로 받은 file_name 변수를 그대로 사용해서 argument 에 넣어도 상관이 없는건지, 별도의 buffer 가 필요한건지 고민중이다. 오늘은 일요일이고 하니 여기서 마무리하고 나머지는 내일 팀원들과 함께 이런저런 시도를 해봐야겠다.

0개의 댓글