Rename RCU CB context to 'cannot block' context
[akaros.git] / kern / src / alarm.c
index 764fdfc..168ceb9 100644 (file)
@@ -45,8 +45,11 @@ void init_timer_chain(struct timer_chain *tchain,
        reset_tchain_times(tchain);
 }
 
-static void __init_awaiter(struct alarm_waiter *waiter)
+void init_awaiter(struct alarm_waiter *waiter,
+                  void (*func) (struct alarm_waiter *awaiter))
 {
+       assert(func);
+       waiter->func = func;
        waiter->wake_up_time = ALARM_POISON_TIME;
        waiter->on_tchain = false;
        waiter->is_running = false;
@@ -54,25 +57,6 @@ static void __init_awaiter(struct alarm_waiter *waiter)
        cv_init_irqsave(&waiter->done_cv);
 }
 
-void init_awaiter(struct alarm_waiter *waiter,
-                  void (*func) (struct alarm_waiter *awaiter))
-{
-       waiter->irq_ok = FALSE;
-       assert(func);
-       waiter->func = func;
-       __init_awaiter(waiter);
-}
-
-void init_awaiter_irq(struct alarm_waiter *waiter,
-                      void (*func_irq) (struct alarm_waiter *awaiter,
-                                        struct hw_trapframe *hw_tf))
-{
-       waiter->irq_ok = TRUE;
-       assert(func_irq);
-       waiter->func_irq = func_irq;
-       __init_awaiter(waiter);
-}
-
 /* Give this the absolute time.  For now, abs_time is the TSC time that you want
  * the alarm to go off. */
 void set_awaiter_abs(struct alarm_waiter *waiter, uint64_t abs_time)
@@ -148,13 +132,8 @@ static void __run_awaiter(uint32_t srcid, long a0, long a1, long a2)
 static void wake_awaiter(struct alarm_waiter *waiter,
                          struct hw_trapframe *hw_tf)
 {
-       if (waiter->irq_ok) {
-               waiter->func_irq(waiter, hw_tf);
-               __finish_awaiter(waiter);
-       } else {
-               send_kernel_message(core_id(), __run_awaiter, (long)waiter,
-                                   0, 0, KMSG_ROUTINE);
-       }
+       send_kernel_message(core_id(), __run_awaiter, (long)waiter,
+                           0, 0, KMSG_ROUTINE);
 }
 
 /* This is called when an interrupt triggers a tchain, and needs to wake up
@@ -296,14 +275,6 @@ bool unset_alarm(struct timer_chain *tchain, struct alarm_waiter *waiter)
                return true;
        }
 
-       /* A common case is that it already finished.  We need the CV lock farther
-        * below so that we don't miss the signal.  You don't need it if you can see
-        * the signal (is_running == false) is already sent. */
-       if (!waiter->is_running) {
-               spin_unlock_irqsave(&tchain->lock);
-               return false;
-       }
-
        /* no_rearm is set and checked under the tchain lock.  It is cleared when
         * unset completes, outside the lock.  That is safe since we know the alarm
         * service is no longer aware of waiter (either the handler ran or we
@@ -312,13 +283,9 @@ bool unset_alarm(struct timer_chain *tchain, struct alarm_waiter *waiter)
        spin_unlock_irqsave(&tchain->lock);
 
        cv_lock_irqsave(&waiter->done_cv, &irq_state);
-       while (1) {
-               if (!waiter->is_running) {
-                       cv_unlock_irqsave(&waiter->done_cv, &irq_state);
-                       break;
-               }
+       while (waiter->is_running)
                cv_wait(&waiter->done_cv);
-       }
+       cv_unlock_irqsave(&waiter->done_cv, &irq_state);
 
        waiter->no_rearm = false;
        return false;
@@ -414,12 +381,8 @@ void print_chain(struct timer_chain *tchain)
               tchain->earliest_time,
               tchain->latest_time);
        TAILQ_FOREACH(i, &tchain->waiters, next) {
-               uintptr_t f;
+               uintptr_t f = (uintptr_t)i->func;
 
-               if (i->irq_ok)
-                       f = (uintptr_t)i->func_irq;
-               else
-                       f = (uintptr_t)i->func;
                printk("\tWaiter %p, time %llu, func %p (%s)\n", i,
                       i->wake_up_time, f, get_fn_name(f));
        }