Skip to content

Instantly share code, notes, and snippets.

@starzia
Last active May 13, 2019 19:41
Show Gist options
  • Save starzia/505626ec439396733b4426f456db401b to your computer and use it in GitHub Desktop.
Save starzia/505626ec439396733b4426f456db401b to your computer and use it in GitHub Desktop.
A xv6 program that makes threads and then exits without cleaning them up.
#include "types.h"
#include "stat.h"
#include "user.h"
void run(void* id) {
printf(1, "hello\n");
volatile int i;
for(i=0; i<100000000; i++);
printf(1, "Child %d done\n", *(int*)id);
}
int main(int argc, char *argv[]) {
int one = 1;
int two = 2;
thread_create(run, &one);
thread_create(run, &two);
printf(1, "now exit without waiting for children\n");
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment