. 'Pintos Project/Project 1' 카테고리의 글 목록
본문 바로가기

Pintos Project/Project 17

[PintOS, Project1] Priority Inversion Problem Priority Inverstion Problem은 thread가 두 개 이상의 lock보유가능할 때, 높은 priority의 thread가 낮은 priority의 thread보다 늦게 실행될 수 있는 문제점을 말한다. 아래 예시를 보자. 그림 1의 상황은 이렇다. 현재 Priority 31의 thread가 running 중이다. (A)는 lock A의 소유권을 가지고 있다는 뜻이다. Read List와 Blocked List가 모두 비어있다. 이제 여기에 lock A를 원하는 높은 priority의 thread가 들어온다고 해보자. 그렇다면 priority가 높은 thread가 running thread가 될 것이다. 39은 running_thread가 되었으나 lock A를 보유하고 있지 않기 때문에.. 2021. 2. 4.
[PintOS, Project1] Priority_Scheduling and Synchronization (semaphore 관련) 지금까지 작업한 pintos에서 thread가 semaphore를 가져가는 순서는 FIFO순으로 되어있다. 이것은 priority가 높은 순으로 semaphore를 가져갈 수 있도록 할 것이다. @/include/threads/synch.h /* A counting semaphore. */ struct semaphore { unsigned value; /* Current value. */ struct list waiters; /* List of waiting threads. */ }; struct semaphore는 semaphore를 관리하기 위한 구조체로서 semaphore의 현재 상태인 value와 이 semaphore를 기다리는 waiters(list 구조체) 가 있다. semaphore와 관련된.. 2021. 2. 4.
[PintOS, Project1] Condition Variable을 이용한 Monitor System Monitor System은 Mutex와 Busy Waiting을 동시에 관리해주는 시스템이다. 어떤 CA(임계영역)의 Mutex를 보장하기 위해서, CA에 관련되어있는 thread는 모두 재우고(Busy waiting 관리, 재운다는 정확한 의미는 차후 서술하겠다.) 오직 하나의 thread만 CA에서 작업하도록 한다(Mutex). 그리고 그 CA에서 작업이 끝나면 자고 있는 thread 중에 한 thread에 signal을 보내서, CA에서 작업하도록 한다. 즉, 어떤 thread가 한 임계영역에 대해 작업하고 있는데, 이 임계영역과 관계가 있는 thread들은 조건이 만족되기 전에는 활동하지 않는다. 이 '조건'을 이용하여 thread를 관리하는 시스템을 Condition Variable을 이용한 .. 2021. 2. 4.
[PintOS, Project1] Priority_Scheduling 과제 목표는 우선순위 스케줄링을 사용하는 것이다. 만약 CPU에 있는 스레드보다 높은 우선순위의 스레드가 들어오면 새로운 스레드가 CPU를 차지한다. 스레드 구조체에 PRI가 들어갈 것 같다. 그리고 스레드의 우선순위를 바꾸는 함수와 우선순위를 반환하는 함수가 들어간다. thread_create() : 스레드를 생성할 때, 우선순위도 지정하도록 바꾼다. unblock과 yield할 때 수정한다는 것은, ready_list에 변화가 있을 때 우선순위별로 정렬하라는 것이다. 이는 list_insert_ordered() 로 정렬한다. 우선 구현할 함수를 선언한다. @/include/threads/thread.h /*-------------------------- project.1-Alarm_Clock ----.. 2021. 2. 3.
[PintOS, Project 1] Alarm Clock 구현 2021/01/31 - [Pintos Project/Project 1] - [PintOS, Project 1] 1/30 : 공부 노트 - 각종 관련 함수들 1. Thread 자료 구조 수정 @/include/threads/thread.h struct thread { /* Owned by thread.c. */ tid_t tid; /* Thread identifier. */ enum thread_status status; /* Thread state. */ char name[16]; /* Name (for debugging purposes). */ int priority; /* Priority. */ /* Shared between thread.c and synch.c. */ struct list_elem.. 2021. 2. 1.
[PintOS, Project 1] 1/30 : 공부 노트 - 각종 관련 함수들 timer_sleep() /* Suspends execution for approximately TICKS timer ticks. */ void timer_sleep (int64_t ticks) { int64_t start = timer_ticks (); ASSERT (intr_get_level () == INTR_ON); while (timer_elapsed (start) < ticks) thread_yield (); } 목적 : (기동 중인 어떤 스레드에 대해서) 기동한 지, 일정 시간이 지나면 thread_yield를 실행한다. - assert : 지정한 조건식이 False 이면 프로그램을 중단하고, True이면 프로그램을 계속 실행한다. - timer_elapsed(start) 가 ticks 보다.. 2021. 1. 31.
[PintOS, Appendix ] Threads Thread struct thread { /* Owned by thread.c. */ tid_t tid; /* Thread identifier. */ enum thread_status status; /* Thread state. */ char name[16]; /* Name (for debugging purposes). */ int priority; /* Priority. */ /* Shared between thread.c and synch.c. */ struct list_elem elem; /* List element. */ #ifdef USERPROG /* Owned by userprog/process.c. */ uint64_t *pml4; /* Page map level 4 */ #endif #i.. 2021. 1. 30.