Esempio n. 1
0
/* Sleeps for approximately TICKS timer ticks.  Interrupts must
   be turned on. */
void
timer_sleep (int64_t ticks) 
{
  int64_t start = timer_ticks ();

  ASSERT (intr_get_level () == INTR_ON);

  /* Changed by Garrett*/
  if (ticks > 0){
    thread_current()->sleep_ticks = ticks;

    //Disable interrupts for thread block
    enum intr_level old_level = intr_disable();

    thread_block();

    //resotre interupt level
    intr_set_level(old_level);

  }

  //End Garrett section

}
Esempio n. 2
0
/* Returns true if Q is full, false otherwise. */
bool
intq_full (const struct intq *q) 
{
  ASSERT (intr_get_level () == INTR_OFF);
  return next (q->head) == q->tail;
}
Esempio n. 3
0
/* Returns true if Q is empty, false otherwise. */
bool
intq_empty (const struct intq *q) 
{
  ASSERT (intr_get_level () == INTR_OFF);
  return q->head == q->tail;
}
Esempio n. 4
0
}

/* Returns the position after POS within an intq. */
static int
next (int pos) 
{
  return (pos + 1) % INTQ_BUFSIZE;
}

/* WAITER must be the address of Q's not_empty or not_full
   member.  Waits until the given condition is true. */
static void
wait (struct intq *q UNUSED, struct thread **waiter) 
{
  ASSERT (!intr_context ());
  ASSERT (intr_get_level () == INTR_OFF);
  ASSERT ((waiter == &q->not_empty && intq_empty (q))
          || (waiter == &q->not_full && intq_full (q)));

  *waiter = thread_current ();
  thread_block ();
}

/* WAITER must be the address of Q's not_empty or not_full
   member, and the associated condition must be true.  If a
   thread is waiting for the condition, wakes it up and resets
   the waiting thread. */
static void
signal (struct intq *q UNUSED, struct thread **waiter) 
{
  ASSERT (intr_get_level () == INTR_OFF);
Esempio n. 5
0
/*! The fullness of the input buffer may have changed.  Reassess
    whether we should block receive interrupts.
    Called by the input buffer routines when characters are added
    to or removed from the buffer. */
void serial_notify(void) {
    ASSERT(intr_get_level() == INTR_OFF);
    if (mode == QUEUE)
        write_ier();
}