Skip to content

Instantly share code, notes, and snippets.

@farhaven
Created October 16, 2012 18:54
Show Gist options
  • Save farhaven/3901216 to your computer and use it in GitHub Desktop.
Save farhaven/3901216 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
#define CHILDREN 50
void
spin(void) {
while (1) {
int fh = open("/dev/kmem", O_RDWR, 0);
if (fh >= 0)
close(fh);
}
}
int
main(void) {
uint32_t i;
for (i = 0; i < CHILDREN; i++) {
pid_t p = fork();
if (p == 0) /* child */
spin();
}
spin();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment