X display locking

2013-03-07 Thread Torsten Jager
Hello!

What is the proper usage of XLockDisplay () / XUnlockDisplay ()
when an application has multiple threads using

  * normal Xlib functions
  * Xitk functions
  * libGL and/or
  * libvdpau ?

On my machine (libX11 1.4.0) bracketing all 4 seems to be necessary
to avoid lockups and stack corruption. At least doing so does
work here.

Hovever, on my mate's box the same code traps both libGL and
libvdepau into an infinite sched_yield () polling loop.

What am I doing wrong?

Torsten
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com


Re: X display locking

2013-03-07 Thread Alan Coopersmith
On 03/ 7/13 06:31 AM, Torsten Jager wrote:
 What is the proper usage of XLockDisplay () / XUnlockDisplay ()
 when an application has multiple threads using

Applications should never call those functions - they are Xlib's
internal locking mechanism for the request buffers.

Applications should only call XInitThreads() to set up the locks
before any Xlib calls are made.

-- 
-Alan Coopersmith-  alan.coopersm...@oracle.com
 Oracle Solaris Engineering - http://blogs.oracle.com/alanc
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com


Re: X display locking

2013-03-07 Thread Aaron Plattner

On 03/07/2013 06:31 AM, Torsten Jager wrote:

Hello!

What is the proper usage of XLockDisplay () / XUnlockDisplay ()
when an application has multiple threads using

   * normal Xlib functions
   * Xitk functions
   * libGL and/or
   * libvdpau ?


XLockDisplay / XUnlockDisplay is only required when you need multiple 
requests to be atomic with respect to requests being sent by other 
threads.  For example, if you have a function like


XGrabServer()
XGetImage()
XUngrabServer()

then you'll probably want to bracket the whole thing with XLockDisplay / 
XUnlockDisplay if you have another thread that could otherwise perform 
rendering during the grab or destroy the window you're trying to 
GetImage or something.



On my machine (libX11 1.4.0) bracketing all 4 seems to be necessary
to avoid lockups and stack corruption. At least doing so does
work here.


You shouldn't get lockups unless you take the lock in one thread and 
don't release it.  You did call XInitThreads() as the very first thing, 
right?



Hovever, on my mate's box the same code traps both libGL and
libvdepau into an infinite sched_yield () polling loop.


Sounds like a bug.


What am I doing wrong?


My guess would be calling XInitThreads too late.  You have to call it 
before anything else, including libraries like libGL and libvdpau, make 
any Xlib calls.



Torsten


--
Aaron
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com