Пример #1
0
int main(void)
{
	init_ports();
	init_timer();
	init_pin_interrupt();
	sei(); // Enable global interrupts
 
	while (1)
    {
		start_sleep();
	}
	return 0;
}
Пример #2
0
/* Sleeps for approximately TICKS timer ticks.  Interrupts must
   be turned on. */
void timer_sleep (int64_t ticks) { 
   ASSERT (intr_get_level () == INTR_ON);  // Interrupts must be on!
   
/* First let's make sure that the number of ticks we want to sleep
   is at least 1. */
   if (ticks < 1) {
     return;
   }

/* What we want to do is set the number of ticks to sleep the thread
   and then whenever there is a timer interrupt we need to check
   if the thread has slept for the appropriate number of ticks.  If it
   has then we must wake up the thread. */
   start_sleep(thread_current(), ticks);
}