Skip to content

Instantly share code, notes, and snippets.

Created February 23, 2011 16:03
Show Gist options
  • Save anonymous/840601 to your computer and use it in GitHub Desktop.
Save anonymous/840601 to your computer and use it in GitHub Desktop.
struct spinlock s;
int doomsday = 0;
doomsday_thr() {
for (;;) {
spin_lock(&s);
while (doomsday == 0) {
spin_unlock(&s);
/* XXX */
tsleep(BADNESS, 0, "waiting-for-end", 0);
spin_lock(&s);
}
go_for_broke();
spin_unlock(&s);
}
}
doomsday_button_intr() {
spin_lock(&s);
doomsday = 1;
spin_unlock(&s);
wakeup(BADNESS);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment