I need a bit of help with a programming assignment and I was hoping someone here could point out what I'm doing wrong. Essentially, I'm trying to create a pthread inside my program. I've looked up literature in my books and also through google, yet I still return an error when I try to use pthread_create(). Here's basically what my code looks like (Oh this is in C btw if I haven't mentioned so already):
Code:
#include <pthread.h>
#include <stdio.h>
void *runner (void *param)
{
printf("Inside pthread\n");
}
int main(int argc, char * argv[])
{
int rc;
pthread_t tid;
pthread_attr_t attr;
pthread_attr_init(&attr);
printf("before\n");
rc = pthread_create(&tid,NULL,runner,(void *)5);
printf("after\n");
if (rc){
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
pthread_join(tid,NULL);
}