/* latex */
핀토스 2~3주차 회고
·
크래프톤 정글/주간 일기
구현Argument PassingSYSCALLFork, Exec, WaitDup2+multi-oompreempt_priority가 list_sort가 있었고 여기서 계속 인터럽트 오류가 났다. 필요 없는 list_sort였기 때문에 삭제해서 해결했지만list_sort 안에enum intr_level old_level = intr_disable();intr_set_level(old_level);를 만들었다.회고 좋았던 점지난 thread주차에 생각했던 개선점을 거의 다 성공해서 좋았다.협업하기syscall자체가 이전보다 역할을 나눠서 만들기가 용이했다. 깃허브에 이슈를 만들고 각자 원하는 시스템 콜들을 가져가는 식으로 작업했다.대충 이런식으로 작업했다. 초반 halt, exit, create 같은 시스템콜..
[Pintos 2-3주차] User Programs: Dup2
·
크래프톤 정글/I Learned
Dup2 설명dup2는 oldfd가 가리키는 파일을 newfd도 가리키게 만드는 함수이다. 핀토스에서는 부모와 자식이 다른 파일을 가리키기 때문에 파일에 몇 명이 가리키는지 ref_count가 없다. 무조건 한 명이 보고있는 일대일 참조 관계이기 때문이다. 그러나 dup2를 사용하면 두 개 이상의 fd테이블이 하나의 파일을 가리킬 수 있다.이에 대한 연쇄효과로 close를 할 때도 가리키고 있는 fd_table이 있으면 닫으면 안 된다. dup2를 할 때 ref_count를 증가시켜야 하고 close 할 때 감소시켜야 한다.또한 dup2가 된 fd_table을 자식이 복사할 때 그 관계도 복사해야한다.부모의 fd[0] = 파일A, fd[1] = 파일A 이라면 자식은 fd[0] = 파일B, fd[1] = ..
[Pintos 2-3주차] User Programs: Fork, Exec, Wait
·
크래프톤 정글/I Learned
Forksyscall.cstatic int s_fork(const char *thread_name, struct intr_frame *f){ s_check_access(thread_name); tid_t child_tid = process_fork(thread_name, f); if (child_tid == TID_ERROR) return TID_ERROR; struct thread *child = get_thread_by_tid(child_tid); struct thread *cur = thread_current(); if (child == NULL) return TID_ERROR; sema_down(&child->fork_sema); ..
[Pintos 2-3주차] User Programs: SYSCALL
·
크래프톤 정글/I Learned
thread 구조체 수정thread.h#define STDIN (struct file *)1#define STDOUT (struct file *)2struct thread{ ... //////////////////////////////////////////////////////////////////////////////////////////////////////#ifdef USERPROG /* Owned by userprog/process.c. */ uint64_t *pml4; /* Page map level 4 */ // userprog int exit_status; struct file **fd_table; int fd_table_size; struct..
핀토스 1주차 회고
·
크래프톤 정글/주간 일기
구현Alarm clockPriority scheduling - dontion제외 Priority scheduling - dontion mlfqs회고좋았던 점 재미있었다일단 아침에 나와서 코어타임 전까지 책을 읽어야 한다는 압박감과 지루함이 사라졌다는 점이 자유롭게 느껴졌다.다른 간섭요소 없이 핀토스에만 집중할 수 있어서 힘든면도 있었지만 재밌는게 더 큰 것 같다. 아쉬웠던 점 우리 팀은 priority를 구현할 때 한 명은 삽입할 때 list_ordered로 넣고 list_front로 꺼내는 방식, 다른 한 명은 push_back 후 max로 꺼내는 방식을 맡아서 진행했다. 근데 이게 문제였다. 큰 차이 없으니까 속도 비교나 해보자 라는 생각으로 시작했는데, 정작 코드가 서로 달라서 병합도 안 되고 ..
[pintos 1주차] Threads: mlfqs구현하기
·
크래프톤 정글/I Learned
기본 설정thread.hstruct thread{ ... int nice; /* 나이스 값(스케줄링에서 사용) */ int recent_cpu; /* 최근 CPU 사용량(스케줄링 계산용) */ struct list_elem all_elem; /* all_list에 들어갈 elem */ ...}void update_load_avg(void);void cal_priority(struct thread *t);void update_recent_cpu_all(void);void update_priority_all(void);void mlfqs_on_tick(void); thread.c#define FIXED (14)#define MUL(x, y) ((((int64_t)(x..
[pintos 1주차] Threads: Donate 구현하기
·
크래프톤 정글/I Learned
먼저 헤더파일부터 수정하겠다헤더파일 수정thread.hstruct thread{ ... struct list locks_hold; /* 스레드가 보유한 락들의 리스트(순서 없음) */ struct lock *waiting_lock; /* 현재 스레드가 기다리고 있는 락 */ int original_priority; /* 기부받지 않은 원래의 우선순위 */ ...} thread.cstatic voidinit_thread(struct thread *t, const char *name, int priority){ ... t->wakeup_tick = 0; //추가 t->original_priority = priority; list_init(&t..
[Pintos 2주차] User Programs: Argument Passing 구현하기
·
카테고리 없음
문제상황 기존 함수userprog/process.c/* Switch the current execution context to the f_name. * Returns -1 on fail. */int process_exec(void *f_name){ char *file_name = f_name; // void* 타입으로 받은 파일 이름을 char*로 변환한다. bool success; /* 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. */ // 새 프로세스의 초기 실..
[Pintos 1주차] Threads: Priority Scheduling 구현하기
·
크래프톤 정글/I Learned
문제는 ready_list 에서 스레드들이 우선순위를 확인하지 않고 그저 큐처럼 push_back, pop_front를 하고있다는 것이다. 따라서 실행될 스레드들 중 우선순위가 가장 높은 스레드를 먼저 꺼내는 구현이 필요하다.구현 방법에는 두 가지가 있다.1. ready_list 에 넣을 때 우선순위 내림차순으로 넣고 뽑을 때 제일 앞을 확인하는 방법2. ready_list 에 넣을 때 push_back하고 뽑을 때 max를 뽑는 방법지금 단계에서만 봤을 때는 1번이 좋아보이지만 우선순위 기부까지 생각하면 2번이 좋을 수도 있을 것 같다.뭐가 좋을지는 모르겠지만 나는 1번 방법으로 구현했다. Threads.hvoid preempt_priority(void);bool priority_greater(cons..
[pintos 1주차] Threads: Alarm Clock 구현하기
·
크래프톤 정글/I Learned
문제 상황timer_sleep(int64_t ticks) 함수는 호출 스레드를 최소 ticks 시간만큼 대기시킨다.기존 구현의 문제점 (Busy Waiting 방식)제공된 초기 구현은 "Busy Waiting (바쁜 대기)" 방식을 채택하고 있다. Busy Waiting은 특정 조건이 충족될 때까지 지속적으로 CPU를 점유하며 무한 루프 내에서 대기하는 방식이다.// (가상의) 기존 timer_sleep() 구현 방식void timer_sleep(int64_t ticks) { int64_t start = timer_ticks(); // 목표 시간이 될 때까지 루프를 돌며 현재 시간을 반복 확인한다. while (timer_elapsed(start) 문제 분석while 루프 안에서 현재 ..