[cairo] Locking policy

Keith Packard keithp at keithp.com
Mon Jun 27 13:43:17 PDT 2005


On Mon, 2005-06-27 at 13:21 -0500, Albert Chin wrote:
> On Sun, Jun 26, 2005 at 09:29:41PM -0700, Keith Packard wrote:
> > I added pthread mutexes to lock the various caches in cairo and (not
> > unexpectedly) this uncovered some 'issues' related to the locking code
> > that is in place.
> 
> Does it matter if the system supports POSIX threads or CMA threads
> (HP-UX 10.20)?

No, the compile auto-detects which kind of threading support you have.
Please look at cairoint.h for the four lines you need to create for your
threading library.  I only did pthreads as that's the only system I can
test against.

And, do note that we have to fix the existing code before it will work
right -- it deadlocks in several places unless you use recursive
mutexes.  This looks easy to fix, fortunately, but it is a bunch of code
review (yuck).

> Also, I just fetched CVS and see you don't link against -lpthread. Are
> you assuming libc has pthread? Or, if stub functions exist in libc,
> they work correctly? I don't know how portable this idea is.

I wouldn't be surprised if some systems need some threading library, but
Linux and the BSDs all use ELF 'weak symbols' to tie libc symbols to the
pthread functions which eliminates all of the locking overhead for
single-thread applications without needing two versions of every
library.

Adding -lpthread would be wrong for Linux and BSD systems.

-keith

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050627/469378ee/attachment.pgp


More information about the cairo mailing list