24.03.15 TIL

lsjoon·2024년 3월 16일
0

TIL

목록 보기
47/51

Weekly Task

  • Project 2 :
    1. Argument Passing (done)
    2. User Memory, System Calls (ongoing)
    3. Process Termination Messages
    4. Denying Writes to Executables
    5. (Extra) Extend File Descriptor

Project 2

2-1. Systemcall 구현 중 (2/13)

Comment

오늘은 Argument Passing 을 빨리 마무리 할 수 있어서 Systemcall 까지 시작할 수 있었다. 그 과정에서 애 먹었던 문제가 하나 있었다.

마지막 exit 에 호출된 파일 이름을 보면, 파싱해준 이름이 아닌 원래의 파일 이름과 인자 값이 그대로 들어가 있는 형태이다.

이 프로세스를 createinit 하는 과정에서, file_name 을 그대로 사용하는 것이 문제였다.

따라서 다음과 같이 const char 로 된 file_name 에서 실제 파일만 분리하는 과정이 필요했다.

tid_t
process_create_initd (const char *file_name) {
	char *fn_copy;
	tid_t tid;

	/* Make a copy of FILE_NAME.
	 * Otherwise there's a race between the caller and load(). */
	fn_copy = palloc_get_page (0);
	if (fn_copy == NULL)
		return TID_ERROR;
	strlcpy (fn_copy, file_name, PGSIZE);

  /* Project 2 - Syscall */
  char *save_ptr;						// 추가된 코드
  char *f_name = strtok_r ((char *)file_name, " ", &save_ptr);			// 추가된 코드

	/* Create a new thread to execute FILE_NAME. */
	tid = thread_create (f_name, PRI_DEFAULT, initd, fn_copy);		// create 할 때 인자를 파싱한 이름으로 변경
	if (tid == TID_ERROR)
		palloc_free_page (fn_copy);
	return tid;
}

profile
중요한 것은 꺾여도 그냥 하는 마음

0개의 댓글