거북이의 쉼터

(2022.02.18) Extend File Descriptor 구현 (3/3) 본문

코딩 삽질/KAIST PINTOS (CS330)

(2022.02.18) Extend File Descriptor 구현 (3/3)

onlim 2022. 2. 18. 14:05

1. 서론 및 필요 내용 설명

아 실행하기 정말 쫄린다. 일단 Make.vars를 수정하고 실행을 해 보자.

 


2. 구현해야 하는 것

Extra 프로젝트를 끝내보자.

 


3. 디버깅

일단 Make.vars를 수정해야 make를 할 때 extra 프로젝트 검사 스크립트가 돌아간다. 우선은 나머지 테스트 케이스는 옆으로 치워두고 dup2-simple, dup2-complex 부터 집중하도록 스크립트를 변경하자. 실행한다.

pass tests/userprog/dup2/dup2-complex
pass tests/userprog/dup2/dup2-simple

통과하네? 왜 아무 문제 없이 동작하는거지? 그럼 multi-oom를 테스트하자.

pass tests/userprog/no-vm/multi-oom

????? 왜냐???? 내 코드에 아무런 문제가 없다고? 그럴리 없어. 전체 실행 make check 딱대.

 

진짜냐? 테스트 케이스를 개별 실행해서 동태를 보자.

warning: TCG doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]
Kernel command line: -q -f put dup2-complex put sample.txt run dup2-complex
0 ~ 9fc00 1
100000 ~ 13e0000 1
Pintos booting with:
        base_mem: 0x0 ~ 0x9fc00 (Usable: 639 kB)
        ext_mem: 0x100000 ~ 0x13e0000 (Usable: 19,328 kB)
Calibrating timer...  314,163,200 loops/s.
hd0:0: detected 329 sector (164 kB) disk, model "QEMU HARDDISK", serial "QM00001"
hd0:1: detected 20,160 sector (9 MB) disk, model "QEMU HARDDISK", serial "QM00002"
hd1:0: detected 125 sector (62 kB) disk, model "QEMU HARDDISK", serial "QM00003"
Formatting file system...done.
Boot complete.
Putting 'dup2-complex' into the file system...
Putting 'sample.txt' into the file system...
Executing 'dup2-complex':
(dup2-complex) open "sample.txt"
(dup2-complex) open "sample.txt"
(dup2-complex) first dup2()
Pintos is funny
child: exit(110)
(dup2-complex) Parent success
dup2-complex: exit(0)
Execution of 'dup2-complex' complete.
Timer: 80 ticks
Thread: 34 idle ticks, 43 kernel ticks, 3 user ticks
hd0:0: 0 reads, 0 writes
hd0:1: 207 reads, 321 writes
hd1:0: 125 reads, 0 writes
Console: 1042 characters output
Keyboard: 0 keys pressed
Exception: 0 page faults
Powering off...

multi-oom 개별 테스트도 일부 수정해서 검사한 결과 EXTRA2 선언이 잘 된 것으로 나온다.

int
main (int argc UNUSED, char *argv[] UNUSED) {
  msg ("begin");

#ifdef EXTRA2
  msg("Extra");
#endif

  int first_run_depth = make_children ();
  CHECK (first_run_depth >= EXPECTED_DEPTH_TO_PASS, "Spawned at least %d children.", EXPECTED_DEPTH_TO_PASS);

  for (int i = 0; i < EXPECTED_REPETITIONS; i++) {
    int current_run_depth = make_children();
    if (current_run_depth < first_run_depth) {
      fail ("should have forked at least %d times, but %d times forked", 
              first_run_depth, current_run_depth);
    }
  }

  msg ("success. Program forked %d iterations.", EXPECTED_REPETITIONS);
  msg ("end");
}
Boot complete.
Putting 'multi-oom' into the file system...
Executing 'multi-oom':
(multi-oom) begin
(multi-oom) Extra
child_6_X: exit(-1)
child_7_X: exit(-1)
child_8_X: exit(-1)
child_9_X: exit(-1)
child_10_X: exit(-1)
...
child_1_O: exit(50)
child_0_O: exit(50)
(multi-oom) success. Program forked 10 iterations.
(multi-oom) end
multi-oom: exit(0)
Execution of 'multi-oom' complete.

별다른 문제 발견이 안된다. 진짜 이걸 원트에 끝낸다고? ㅋㅋㅋㅋㅋㅋ 좀 허무하지만 그래... 어제 고생 많이 했지. 다음 포스팅부터는 이제 프로젝트 3을 보자.

 


4. 후기

딱 이건데

이럴 거였으면 어제 포스팅 때 끝냈지... 오늘은 놀러 갑니다.

Comments