Alarm to abort syscalls, should be used in ping
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 22 Nov 2013 18:39:08 +0000 (10:39 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 16 Jan 2014 21:07:51 +0000 (13:07 -0800)
Will need to reorganize a lot of userspace's libraries.  Stuff like
nsec2tsc() doesn't need to be in a benchmarking library.  Same goes for
the alarm stuff; benchutil is more of a "everything I can't put in
parlib that we want by default."

user/benchutil/alarm.c
user/benchutil/include/alarm.h

index 811e998..4bb1108 100644 (file)
@@ -393,3 +393,20 @@ void print_chain(struct timer_chain *tchain)
               tchain->latest_time);
        spin_pdr_unlock(&tchain->lock);
 }
+
+/* "parlib" alarm handlers */
+void alarm_abort_sysc(struct alarm_waiter *awaiter)
+{
+       struct uthread *uth = awaiter->data;
+       assert(uth);
+       if (!uth->sysc) {
+               /* It's possible the sysc hasn't blocked yet or is in the process of
+                * unblocking, or even has returned, but hasn't cancelled the alarm.
+                * regardless, we request a new alarm (the uthread will cancel us one
+                * way or another). */
+               set_awaiter_inc(awaiter, 1000000);
+               __set_alarm(awaiter);
+               return;
+       }
+       sys_abort_sysc(uth->sysc);
+}
index 39e0776..b4cd24e 100644 (file)
@@ -72,8 +72,11 @@ void set_alarm(struct alarm_waiter *waiter);
 bool unset_alarm(struct alarm_waiter *waiter);
 void reset_alarm_abs(struct alarm_waiter *waiter, uint64_t abs_time);
 
+/* "parlib" alarm handlers */
+void alarm_abort_sysc(struct alarm_waiter *awaiter);
+
 /* Debugging */
 #define ALARM_POISON_TIME 12345
 void print_chain(struct timer_chain *tchain);
 
-#endif /* ROS_KERN_ALARM_H */
+#endif /* _ALARM_H */