Skip to content

Instantly share code, notes, and snippets.

Created February 23, 2011 16:07
Show Gist options
  • Save anonymous/840611 to your computer and use it in GitHub Desktop.
Save anonymous/840611 to your computer and use it in GitHub Desktop.
struct spinlock s;
int doomsday = 0;
doomsday_thr() {
for (;;) {
spin_lock(&s);
while (doomsday == 0) {
tsleep_interlock(BADNESS, 0);
spin_unlock(&s);
tsleep(BADNESS, PINTERLOCK, "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