+/* Handles an unexpected interrupt with interrupt frame F. An
+ unexpected interrupt is one that has no registered handler. */
+static void
+unexpected_interrupt (const struct intr_frame *f)
+{
+ /* Count the number so far. */
+ unsigned int n = ++unexpected_cnt[f->vec_no];
+
+ /* If the number is a power of 2, print a message. This rate
+ limiting means that we get information about an uncommon
+ unexpected interrupt the first time and fairly often after
+ that, but one that occurs many times will not overwhelm the
+ console. */
+ if ((n & (n - 1)) == 0)
+ printf ("Unexpected interrupt %#04x (%s)\n",
+ f->vec_no, intr_names[f->vec_no]);
+}
+