Altera_Forum
Honored Contributor
20 years agoProblems with pthreds
I'm a program benchmark with pthreads, but I'm having really problems with it. Now i'm only want to do a simple hello world, but when I execute it the uClinux reinit another time. Can someone help me please? Can put some example that really run? Thanks to all.
# include <stdio.h># include <unistd.h># include <stdlib.h># include <pthread.h># include <sched.h># include <errno.h> void print_message_function( void ){ char message = "Hello"; printf("%s ", message); pthread_exit(NULL); } void main (int argc, char *argv[]){ pthread_t thread1, thread2; //char *message1 = "Hello"; //char *message2 = "World"; //pthread_attr_t pthread_attr_default; printf("\nThread 1"); pthread_create( &thread1, NULL, (void*)&print_message_function, NULL); printf("\nThread 2"); pthread_create( &thread2, NULL, (void*)&print_message_function, NULL); pthread_exit(NULL); exit(0); }