Subject: Re: pthreads, Xlib and me ...
To: leon zadorin <leonleon77@gmail.com>
From: Bill Stouder-Studenmund <wrstuden@netbsd.org>
List: port-macppc
Date: 03/29/2007 09:34:41
--RnlQjJ0d97Da+TV1
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Mar 28, 2007 at 03:38:01PM +1000, leon zadorin wrote:
> On 3/28/07, Bill Stouder-Studenmund <wrstuden@netbsd.org> wrote:
> >I know very little about X, but aren't you supposed to be calling
> >XLockDisplay at points?
>=20
> mmm... I was under the impression that it would only be needed if a
> given pointer to  Display (as obtained from XOpenDisplay) was accessed
> from multiple threads... now, since (in my sample) the XOpenDisplay
> returns a pointer which is only being accessed from the very thread
> that called XOpenDisplay, then AFAIK one does not need to call
> XLockDisplay...

I don't think so. You explicitly told X that you're in a multi-threaded=20
environment, and for X that means locking. If an X library call expects=20
something to be locked, you need to have it locked before making the call.

> I mean the very signature of XLockDisplay takes a pointer to Display
> which is to be locked: "The XLockDisplay() function locks out all
> other threads from using the specified display"...
>=20
> In other words, my understanding is that if different threads use
> XOpenDisplay and do not "cross-touch" the Display pointers (returned
> by their respective XOpenDisplay calls) then there is no need to call
> XLockDisplay...

While you are right that there will be no other thread you need to lock=20
out from accessing the display, that doesn't mean you can ignore the=20
locking that the library expects. The error you're getting is "Unlocking=20
unlocked mutex." That means the library expected something locked and it=20
isn't getting one.

> In my sample, there was only 1 thread which did both: called
> XOpenDisplay and accessed it (via  glXQueryExtension and
> glXQueryVersion)...
>=20
> But I would welcome more info or arguments on this subject :-)

Try the locking.

Oh, I haven't had a chance to test this program on macppc.

Take care,

Bill

--RnlQjJ0d97Da+TV1
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (NetBSD)

iD8DBQFGC/ixWz+3JHUci9cRArauAJwLp1e98xkTciSVo+G+s7zjsXUEHACgk5C5
DJPNoxTiujZ0dBFsF8qBnSc=
=yumV
-----END PGP SIGNATURE-----

--RnlQjJ0d97Da+TV1--