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:
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:
//ok, this is the time for the thread to work
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.
using namespace std;
void* show( void* param )
cout << "testing" << endl;
pthread_create( &thread_id, NULL, &show, NULL );