[Xcb] problem with xcb-based Xlib and multithreaded applications

Francesco Abbate francesco.bbt at gmail.com
Tue Jan 4 05:38:43 PST 2011


Hi Uli,

thank you very much for taking the time to look at my problem, I
appreciate a lot.

> Uhm, what do you need threads for? Only one thread can be active at any given
> time with such a looking scheme, no?

For my applications it is needed because the main thread (thread #1)
treats the incoming events to refresh the window as needed. The thread
#2 does take the input from the user from the TTY, does execute the
user commands by using a scripting language (Lua) and can, if
requested, draw new elements into the graphical windows. So the two
threads are needed because the thread #2 can be busy while executing a
script and at the same time we need the window to remain responsive to
Configure/Expose events at least, so a separate thread is needed.

> attached is an ugly (e.g. drawing without getting an Expose) test case. The main
> thread just does XNextEvent and prints all events while a thread does some
> drawing via XFillRectangle every second. My libX11 uses xcb:
>
> $ ldd /usr/lib/libX11.so | grep xcb
>        libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007f5b9b3ac000)
>
> However, I don't see any hangs from this. It all seems to work fine. What am I
> doing wrong that makes this work correctly?

Well, you example seems to be pertinent. The only objection I can
think about is that I'm using XPutImage instead of XFillRectangle,
like you are doing, and I was using XSync with Discard to True.

Anyway, for the moment I cannot do any test but this evening I will
use your test program to try it and see if I can modify it to
reproduce the bug. I will give you a feedback soon, thank you for your
help!

Francesco



-- 
Francesco


More information about the Xcb mailing list