[Pint OS] System Calls (1)
·
프로젝트/Pint OS
x86-64 기반 Pint OS 프로젝트 2의 System Calls를 구현하기 위해 공부한 개념을 정리한다. Implementation userprog/syscall.c에서 system call handler를 구현한다. 핀토스에서 기본적으로 제공된 스켈레톤 코드는 system call을 오직 프로세스 종료로만 다룬다. 우리는 system call number와 argument를 읽고, 적절한 actions을 수행하도록 해야한다. System Call Detail 전통적인 x86 아키텍처에서 시스템 콜은 다른 software exceptions와 동일하게 처리되었다. 그러나 x86-64 아키텍처부터 설계자들은 syscall이라는 특수한 명령어를 도입하여 시스템 콜 핸들러를 빠르게 호출하는 방법을 마련했..
[Pint OS] User Memory Access
·
프로젝트/Pint OS
Virtual Memory Layout Pint OS에서 가상 메모리는 2개의 영역으로 나뉜다. User Virtual Memory: 가상 주소 0부터 KERN_BASE(0x8004000000) 사이의 영역 Kernel Virtual Memory: 가상 주소 KERN_BASE(0x8004000000) 이상의 영역 User Virtual Memory 유저 가상 메모리는 프로세스마다 할당된다. 커널이 한 프로세스를 다른 프로세스로 전환할 때, 페이지 테이블을 통해 유저 가상 주소 공간도 전환된다(Context Switching).구조체 thread는 프로세스의 페이지 테이블을 가리키는 포인터를 가지고 있다(curr_thread->pml4). 유저 프로그램은 오직 할당된 유저 가상 메모리에만 접근할 수 있다...
[Pint OS] 에러: Kernel panic... thread_yield()
·
프로젝트/Pint OS
발생 Pint OS의 프로젝트 2, argument passing을 실행시켜보았다가 발생했다. formatting file system을 하다가 터진다. Kernel panic in run: PANIC at ../../threads/thread.c:338 in thread_yield(): assertion `!intr_context ()' failed. * backtrace Call stack: 0x800421874b 0x80042072c0 0x800420a92f 0x8004214d12 0x8004209704 0x8004209b22 0x800420762b Translation of call stack: 0x000000800421874b: debug_panic (lib/kernel/debug.c:32) 0..
[Pint OS] Argument Passing
·
프로젝트/Pint OS
Requirement thread.h에 #define USERPROG 선언 process_exec() 함수 수정 /* Switch the current execution context to the f_name. * Returns -1 on fail. */ int process_exec (void *f_name) { /* ... */ /* for project 2 * todo: implementation argument passing */ int argc = 0; char *argv[64]; char *ret_ptr, *next_ptr; ret_ptr = strtok_r(file_name, " ", &next_ptr); while(ret_ptr) { argv[argc++] = ret_ptr; ret_ptr..