전체 글

PintOS

Project 1 : Priority Scheduling - BeAPro

To do - 1 지금 PintOS에서는 쓰레드들이 ready_list에 삽입된 순서대로(Round-Robin) 실행되고 있다. Round-Robin 방식은 쓰레드들의 대기 시간의 총합을 늘릴 수 있기 때문에 각 쓰레드마다 우선순위를 부여하고 우선순위가 높은 쓰레드부터 작업될 수 있도록 한다. 위 동작을 편리하게 하기 위해 list에 삽입되는 쓰레드들이 우선순위가 높은 순으로 정렬한다. ready_list와 synchronization primitives(semaphore, condition variable)에 있는 wait list에 대해 정렬을 해야 한다. Priority order insert ready_list /* thread.c */ bool cmp_priority(const struct li..

PintOS

Project 1 : Alarm clock - BeAPro

Alarm clock /* tests/thread/alarm-priority.c */ .... timer_sleep (wake_time - timer_ticks ()); alarm을 테스트하는 c파일에서는 timer_sleep() 함수를 불러온다. 현재 PintOS는 busy waiting 방식으로 알람이 구현되어 있다. void timer_sleep (int64_t ticks) { int64_t start = timer_ticks (); ASSERT (intr_get_level () == INTR_ON); while (timer_elapsed (start) < ticks) thread_yield (); } busy waiting 방식은 아무것도 하지 않는 쓰레드가 CPU를 점유하고 있는 매우 비효율적인..

PintOS

Project 1 : synch 코드리뷰 - BeAPro

synch.h /* A counting semaphore. */ struct semaphore { unsigned value; /* Current value. */ struct list waiters; /* List of waiting threads. */ }; /* Lock. */ struct lock { struct thread *holder; /* Thread holding lock (for debugging). */ struct semaphore semaphore; /* Binary semaphore controlling access. */ }; /* Condition variable. */ struct condition { struct list waiters; /* List of waiting ..

BeAPro
BeAPro