Hi, not sure what response I will get here but I'm doing some programming on w32 using cygwin (I know this is linux forum but cygwin, gcc and pthreads seem more applicable here)
I'm trying to get pthreads to use both cores on my system but the code I have uses no more then if I just run the same proccess in a single thread.
Task manager shows 25% on both cores, can't get it to go any higher.
Code im using to initiate the threads are as follows,
pthread_t thread1, thread2;
char *message1 = "Thread 1 finished";
char *message2 = "Thread 2 finished";
int iret1, iret2;
//start thread(s)
iret1 = pthread_create( &thread1, NULL, myfunction_t1, (void*) message1);
iret2 = pthread_create( &thread2, NULL, myfunction_t2, (void*) message2);
//implement second thread divide work properly
pthread_join( thread1, NULL);
pthread_join( thread2, NULL);
As far as I'm aware that should be it, if I get both functions to blot output to screen I see output from each function one after another but I can't get it to use all my cpu power.
Any advice?
I'm trying to get pthreads to use both cores on my system but the code I have uses no more then if I just run the same proccess in a single thread.
Task manager shows 25% on both cores, can't get it to go any higher.
Code im using to initiate the threads are as follows,
pthread_t thread1, thread2;
char *message1 = "Thread 1 finished";
char *message2 = "Thread 2 finished";
int iret1, iret2;
//start thread(s)
iret1 = pthread_create( &thread1, NULL, myfunction_t1, (void*) message1);
iret2 = pthread_create( &thread2, NULL, myfunction_t2, (void*) message2);
//implement second thread divide work properly
pthread_join( thread1, NULL);
pthread_join( thread2, NULL);
As far as I'm aware that should be it, if I get both functions to blot output to screen I see output from each function one after another but I can't get it to use all my cpu power.
Any advice?