Hi, I have problem with my code. In Fedora Core 4, I could compile and run it. Then I changed distro to Ubuntu Breezy Badger ( 5.10 ). I can compile it and when I run it, I get segmentation fault.
Here is the code:
http://www.akbarhome.com/download/te..._wallpapoz.cpp
It is 245 lines. You don't have to read all the lines. The problem lies in this section:
If I comment the pthread_create line, the program runs fine, of course without the additional feature that depend on thread. You must remember that this code runs fine in Fedora Core 4 ( without segmentation fault ). I try test the simple code with pthread_create in Ubuntu distro like this:Code://ok, this is the time for the thread to work int thread_param[workspace_total]; for( int j=0; j<workspace_total; j++ ) { thread_param[j] = j; pthread_create( &thread_id[j], NULL, &show_wallpaper, &thread_param[j]); }
And it runs fine. I am confuse. Any body can help me? I don't know how to debug thread. The only way I know to debug thread is with printf or cout. It get segmentation fault before it execute the first line of function that thread go in, that is show_wallpaper.Code:#include <iostream> using namespace std; void* show( void* param ) { cout << "testing" << endl; } int main() { pthread_t thread_id[4]; pthread_create( &thread_id[0], NULL, &show, NULL ); while(true) {} }
Thank you.



LinkBack URL
About LinkBacks


