thread deadlock strangitude !



Hi there,

I am running a multi thread program .... I use the kernel 'clone' function
to thread with.
My main program looks pretty much like this ....

main(){ //C++ code
  g_thread_init(NULL);
  GtkInterface topWindow; //encapsulates gtk_init();

  gdk_threads_enter();
  gtk_main();
  gdk_threads_leave();
  return 0;
}

Now I have this simple drawing routine :
  void update(void){
    cout <<"fieldInterface : update enter"<<endl;
    for (int i=0;i<digitCnt();i++){
      int which=field<TYPE>::digits[digitCnt()-i-1];

      cout<<"Sema lock"<<endl;
      gdk_threads_enter()

      cout<<"Set pixmap"<<endl;
      gtk_pixmap_set(digitsGtk[i], digitsGdk[which], (GdkPixmap*)NULL);

      cout<<"Sema UNlock"<<endl;
      gdk_threads_leave()
    }
  }

Which when run outputs :

fieldInterface : update enter
Sema lock
Set pixmap
Sema UNlock
Sema lock
Set pixmap
Sema UNlock
Sema lock
Set pixmap
Sema UNlock
Sema lock
Set pixmap
Sema UNlock
Sema lock
Set pixmap
Sema UNlock

FieldInterface: digitPress // this is a button press style event
fieldInterface : update enter
Sema lock



As you can see there are no spurious double 'Sema lock' calls, so I don't
believe a deadlock should occur ! #@#?! #

It is strange that the same problem occurs when the program is threaded or
is waiting for the button press to spawn a new thread !


help would be greatly appreciated !
thanks
Matt






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]