728x90
PintOS
Project2가 끝이났다.
처음에는 엄청 어려웠지만 끝나는 오늘와서 생각해보니 더 어려웠다.
fork ,wait 진짜 미친 난이도 정말 너무 너무 어려웠다.
Project 정리로 한번에 정리해서 올리도록 하겠다.
wait , exec, fork 개발을 완료했다. 아쉽게 multi_oom은 테스트 통과하지 못했다 ㅠㅜㅠ
tid_t
process_fork (const char *name, struct intr_frame *if_) {
/* Clone current thread to new thread.*/
struct parent_info my_data;
my_data.parent = thread_current();
my_data.parent_f = if_;
struct thread *cur = thread_current();
memcpy(&cur->parent_tf, my_data.parent_f , sizeof(struct intr_frame));
tid_t tid = thread_create(name, PRI_DEFAULT, __do_fork, &my_data);
if (tid == TID_ERROR){
return TID_ERROR;
}
struct thread *child = get_thread_from_tid(tid);
sema_down(&child->process_sema);
if(child->exit_status == TID_ERROR)
{
sema_up(&child->exit_sema);
return TID_ERROR;
}
return tid;
}
static bool
duplicate_pte (uint64_t *pte, void *va, void *aux) {
struct thread *current = thread_current ();
struct thread *parent = (struct thread *) aux;
void *parent_page;
void *newpage;
bool writable;
if (is_kernel_vaddr(va)){
return true;
}
parent_page = pml4_get_page (parent->pml4, va);
if (parent_page == NULL){
return false;
}
newpage = palloc_get_page(PAL_USER);
if (newpage == NULL){
return false;
}
memcpy(newpage, parent_page, PGSIZE);
writable = is_writable(pte);
if (!pml4_set_page (current->pml4, va, newpage, writable)) {
return false;
}
return true;
}
static void
__do_fork (struct parent_info *aux) {
struct intr_frame if_;
struct thread *parent = aux->parent;
struct thread *current = thread_current ();
struct intr_frame *parent_if = aux->parent_f;
bool succ = true;
memcpy(&if_, parent_if, sizeof(struct intr_frame));
if_.R.rax = 0; // 자식 프로세스의 리턴값은 0
/* 2. Duplicate PT */
current->pml4 = pml4_create();
if (current->pml4 == NULL)
goto error;
process_activate(current);
struct list_elem* e = list_begin(&parent->fd_table);
struct list *parent_list = &parent->fd_table;
if(!list_empty(parent_list)){
for (e ; e != list_end(parent_list) ; e = list_next(e)){
struct file_descriptor* parent_fd =list_entry(e,struct file_descriptor, fd_elem);
if(parent_fd->file != NULL){
struct file_descriptor *child_fd = malloc(sizeof(struct file_descriptor));
child_fd->file = file_duplicate(parent_fd->file);
child_fd->fd = parent_fd->fd;
list_push_back(¤t->fd_table, & child_fd->fd_elem);
}
current->last_created_fd = parent->last_created_fd;
}
current->last_created_fd = parent->last_created_fd;
} else {
current->last_created_fd = parent->last_created_fd;
}
if_.R.rax = 0;
// 로드가 완료될 때까지 기다리고 있던 부모 대기 해제
sema_up(¤t->process_sema);
process_init();
}
- 자세한 설명은 Project2 설명에 적어놓겠다 많관부
pass tests/userprog/args-none
pass tests/userprog/args-single
pass tests/userprog/args-multiple
pass tests/userprog/args-many
pass tests/userprog/args-dbl-space
pass tests/userprog/halt
pass tests/userprog/exit
pass tests/userprog/create-normal
pass tests/userprog/create-empty
pass tests/userprog/create-null
pass tests/userprog/create-bad-ptr
pass tests/userprog/create-long
pass tests/userprog/create-exists
pass tests/userprog/create-bound
pass tests/userprog/open-normal
pass tests/userprog/open-missing
pass tests/userprog/open-boundary
pass tests/userprog/open-empty
pass tests/userprog/open-null
pass tests/userprog/open-bad-ptr
pass tests/userprog/open-twice
pass tests/userprog/close-normal
pass tests/userprog/close-twice
pass tests/userprog/close-bad-fd
pass tests/userprog/read-normal
pass tests/userprog/read-bad-ptr
pass tests/userprog/read-boundary
pass tests/userprog/read-zero
pass tests/userprog/read-stdout
pass tests/userprog/read-bad-fd
pass tests/userprog/write-normal
pass tests/userprog/write-bad-ptr
pass tests/userprog/write-boundary
pass tests/userprog/write-zero
pass tests/userprog/write-stdin
pass tests/userprog/write-bad-fd
pass tests/userprog/fork-once
pass tests/userprog/fork-multiple
pass tests/userprog/fork-recursive
pass tests/userprog/fork-read
pass tests/userprog/fork-close
pass tests/userprog/fork-boundary
pass tests/userprog/exec-once
pass tests/userprog/exec-arg
pass tests/userprog/exec-boundary
pass tests/userprog/exec-missing
pass tests/userprog/exec-bad-ptr
pass tests/userprog/exec-read
pass tests/userprog/wait-simple
pass tests/userprog/wait-twice
pass tests/userprog/wait-killed
pass tests/userprog/wait-bad-pid
pass tests/userprog/multi-recurse
pass tests/userprog/multi-child-fd
pass tests/userprog/rox-simple
pass tests/userprog/rox-child
pass tests/userprog/rox-multichild
pass tests/userprog/bad-read
pass tests/userprog/bad-write
pass tests/userprog/bad-read2
pass tests/userprog/bad-write2
pass tests/userprog/bad-jump
pass tests/userprog/bad-jump2
pass tests/filesys/base/lg-create
pass tests/filesys/base/lg-full
pass tests/filesys/base/lg-random
pass tests/filesys/base/lg-seq-block
pass tests/filesys/base/lg-seq-random
pass tests/filesys/base/sm-create
pass tests/filesys/base/sm-full
pass tests/filesys/base/sm-random
pass tests/filesys/base/sm-seq-block
pass tests/filesys/base/sm-seq-random
pass tests/filesys/base/syn-read
pass tests/filesys/base/syn-remove
pass tests/filesys/base/syn-write
FAIL tests/userprog/no-vm/multi-oom
pass tests/threads/alarm-single
pass tests/threads/alarm-multiple
pass tests/threads/alarm-simultaneous
pass tests/threads/alarm-priority
pass tests/threads/alarm-zero
pass tests/threads/alarm-negative
pass tests/threads/priority-change
pass tests/threads/priority-donate-one
pass tests/threads/priority-donate-multiple
pass tests/threads/priority-donate-multiple2
pass tests/threads/priority-donate-nest
pass tests/threads/priority-donate-sema
pass tests/threads/priority-donate-lower
pass tests/threads/priority-fifo
pass tests/threads/priority-preempt
pass tests/threads/priority-sema
pass tests/threads/priority-condvar
pass tests/threads/priority-donate-chain
1 of 95 tests failed.
- 진행정도
힘들었지만 그래도 끝냈다. 후!
프로젝트3 잘해보자
728x90
'Study > TIL(Today I Learned)' 카테고리의 다른 글
24.03.22 운영체제, KEYWORD (1) | 2024.03.23 |
---|---|
24.03.21 운영체제 (0) | 2024.03.21 |
24.03.19 퀴즈, 운영체제, PintOS (1) | 2024.03.19 |
24.03.18 운영체제, KEYWORD, PintOS (1) | 2024.03.19 |
24.03.17 운영체제, PintOS (1) | 2024.03.17 |