sw사관학교정글/PintOS(KAIST's CS330 class) 15

[week12] PintOS - Project 3(Virtual Memory) : 핀토스는 확률게임인가

Project 3 : 핀토스는 확률게임인가 현재상황 FAIL tests/filesys/base/syn-read FAIL tests/userprog/create-null FAIL tests/userprog/open-null FAIL tests/vm/swap-file FAIL tests/vm/swap-anon FAIL tests/vm/swap-iter FAIL tests/vm/swap-fork FAIL tests/vm/cow/cow-simple //extra 수정 시작 swap tests를 고쳐보자. victim을 찾아야 되는데 return 을 NULL로 하고 있었다. static struct frame * vm_evict_frame (void) { // project 3 struct frame *victi..

[week11] PintOS - Project 3(Virtual Memory) : Swap In/Out

Project 3 : Swap In/Out 구현 무엇을 하는가? Memory swapping은 physical memory 사용을 극대화하기 위한 memory 회수 기법이다. main memory의 frame이 할당되면 system은 user program의 메모리 할당 요청을 더 이상 처리할 수 없다. 한 가지 해결책은 최근에 사용되지 않는 memory frame을 disk로 교체하는 것이다. 이렇게 하면 일부 memory resource가 확보되어 다른 응용프로그램에서 사용 가능해진다. 가상 주소 안의 VPN에 Present Bit을 두어 해당 페이지가 디스크로 스왑되었는지를 나타낸다. swapping은 OS 에 의해 실행된다. system에서 memory가 부족한데 메모리 할당 요청을 받으면 교환할..

[week11] PintOS - Project 3(Virtual Memory) : Memory mapped files

Project 3 : Memory mapped files 구현 무엇을 하는가? 이 섹션에서는 memory-mapped pages를 구현한다. anonymous pages와 달리 memory-mapped pages는 file-backed mapping이다. page의 내용들은 현재 file의 data들을 복사해 온 내용들이다. page fault가 발생하면 physical frame이 즉시 할당되고 파일로부터 메모리로 내용이 복사된다. memory-mapped pages가 unmapped되거나 swap out 되면, contents의 수정사항이 file에 반영된다. mmap의 장단점 장점 프로세스가 가지고 있는 읽기 혹은 쓰기 buffer에 복사해서 data를 가져오는 것이 아니라 바로 file에서 가져와..

[week11] PintOS - Project 3(Virtual Memory) : Stack growth

Project 3 : Stack growth 구현 무엇을 하는가? project 2에서 stack은 USER_STACK부터 시작하는 단일 page였으며 프로그램의 실행은 이 크기로 제한되었다. 이제 stack이 현재 크기를 초과하면 필요에 따라 추가 page를 할당한다. page fault가 발생했을 때, 이 page fault가 stack growth에 대한 page fault인 경우, stack을 키운다. stack growth 기능 구현 먼저 syscall handler를 수정한다. void syscall_handler (struct intr_frame *f UNUSED) { #ifdef VM thread_current()->rsp_stack = f->rsp; #endif ... } system c..

[week11] PintOS - Project 3(Virtual Memory) : Anonymous Page

Project 3 : Anonymous Page 구현 무엇을 하는가? anonymous page를 구현하는 것이 목표이다. anonymous page가 무엇인가? anonymous page는 file-backed page와 달리 contents를 가져올 file이나 device가 없는 page를 말한다. 이들은 프로세스 자체에서 런타임 때 만들어지고 사용된다. stack 과 heap 영역의 메모리들이 여기에 해당된다. vm_alloc_page_with_initializer()를 구현해야 한다. 이 함수의 역할은 전달된 vm_type에 따라 적절한 initializer를 가져와서 uninit_new를 호출하는 역할이다. // vm/vm.c /* Create the pending page object wit..

[week10] PintOS - Project 3(Virtual Memory) : Memory Management

Project 3 : Memory Management 구현 우리가 무엇을 하는가? PintOS는 메모리의 가상 및 물리적 매핑을 관리하기 위한 page table(pml4)이 있다. 하지만 이것만으로는 충분하지 않다. page fault 및 resource management를 처리하기 위해 각 page에 대한 추가 정보를 저장할 수 있는 supplementary page table이 필요하다. supplemental_page_table 구현 supplemental_page_table을 hash table을 사용해서 구현해보자. hash 구조체는 다음과 같다. // include/lib/kernel/hash.h /* Hash table. */ struct hash { size_t elem_cnt; /* ..

[week09] PintOS - Project 2(User Programs) : System Calls All Pass 받기 위한 험난한 과정

앞선 게시물과 중복되는 코드가 있을 수 있다. 왜냐하면 All Pass 를 받고나서 정리를 했기 때문이다. 그래도 혹시 같은 문제로 고생하는 사람들을 위해 내가 어떻게 문제를 해결했는지 정리해 놓은 것을 공유한다. 확실히 fail을 pass로 만드는 과정에서 더 알아보게 되고, 더 남는게 많은 것 같다. 현재 8개 fail FAIL tests/userprog/open-twice FAIL tests/userprog/read-stdout FAIL tests/userprog/write-stdin FAIL tests/userprog/exec-read FAIL tests/userprog/rox-simple FAIL tests/userprog/rox-child FAIL tests/userprog/rox-multic..