All pastes #1735943 Raw Edit

bblum

public text v1 · immutable
#1735943 ·published 2010-01-03 07:31 UTC
rendered paste body
#define _GNU_SOURCE#include <sched.h>#include <unistd.h>#include <stdio.h>#include <stdlib.h>#include <sys/syscall.h>#define NUM_THREADS 64#define STACK_SIZE 4096char *stack[NUM_THREADS];int foobar(void *arg){	printf("thread %lu\n", (unsigned long)arg);	fflush(stdout);	while (1)		pause();	return 0;}int main(){	unsigned long i;	for (i = 0; i < NUM_THREADS; i++) {		stack[i] = malloc(STACK_SIZE);		clone(foobar, stack[i], CLONE_THREAD | CLONE_VM | CLONE_SIGHAND, (void *)i);	}	syscall(__NR_exit, 0);}