timer_interrupt() - 인터럽트 발생 함수(thread wake 기능이 구현되어야 한다)
/* Timer interrupt handler. */
static void
timer_interrupt (struct intr_frame *args UNUSED) {
ticks++;
thread_tick ();
// next_tick = get_next_tick_to_awake();
thread_awake(ticks);
}
timer_sleep() - thread_sleep함수 호출
void
timer_sleep (int64_t ticks) { // sleep until 까지 더 자야하는 시간 = ticks
int64_t start = timer_ticks ();
struct thread *curr = thread_current();
ASSERT (intr_get_level () == INTR_ON);
// 일어날 시간은 현재시간 + 더 자야하는시간 (ticks)
// osiete
thread_osiete(ticks);
if(ticks > 0) thread_sleep();
else if (ticks == 0) thread_yield();
else return;
}
timer_sleep()
void thread_sleep(void) {
struct thread *curr = thread_current();
// curr->wakeup_tick = ticks + timer_ticks();
ASSERT(curr->status == THREAD_RUNNING);
enum intr_level old_level = intr_disable ();
list_push_back(&sleep_list, &(curr->elem));
thread_block();
intr_set_level (old_level);
}
인터럽트를 쓰지않고 깨우는 방법을 고민하다가
메인스레드만 재우지 않고 timer_awake를 메인스레드에서 돌리는 방식으로 구현하였다.
통과 - alarm-single, alarm-multiple
실패 - alarm-simultaneous
이유는?)