problem with multithreaded application and Xlib

Francesco Abbate francesco.bbt at gmail.com
Tue Sep 28 08:19:37 PDT 2010


Hi all,

I've recently made the switch to the snapshot xorg server and the
related X libraries and I've discovered that my application stopped to
works correctly!

Here the problem in short. I'm developing a multi-threaded application
where the main thread run the X Window event loop. There is also a
secondary thread that sometimes need to redraw the window or, more
generally, perform operation on the X Display. In order to avoid
problems I've arranged some locks so that the secondary thread perform
its operations on the display only when the main thread is blocking in
the XNextEvent operation. At this point is important to add that, yes,
I'm using the XInitThread functions at the very beginning of the main
loop.

What happens is that the secondary thread blocks during the XSync
operation until the main thread receive some events.

I'm wondering if the assumption that I'm doing in my code is wrong or
if it is a bug of the X server or may be the X library. It seems to me
that it is like if Xlib does not honor the XInitThreads call because
it does not allow an ordinary XSync to terminate if there is a pending
XNextEevent call at the same time (by another thread).

I hope someone can help me to clarify the problem.

Best regards,
Francesco


More information about the xorg-devel mailing list