#include #include #include void *child(void *arg); struct thread_data{ int amount; int period; int iterations; }; /* create a new thread that allocates memory returns the new process id */ int start_periodic(int amount, int period, int iterations) { pthread_t tid; struct thread_data args; args.amount = amount; args.period = period; args.iterations = iterations; if (pthread_create(&tid, NULL, child, &args) != 0) { /* error creating child, to stderr */ } printf("created child: %d\n", tid); return 1; } void *child(void *arg) { struct thread_data * my_data; my_data = (struct thread_data *) arg; int period = *my_data.period; int amount = *my_data.amount; int iterations = *my_data.iterations; return arg; }