Linux posix threads and X11R6's thread interface

Linux posix threads and X11R6's thread interface

Post by Michael Huehn » Wed, 09 Oct 1996 04:00:00



Hi Xavier and Sean
and all you unknown folks,

I have   seen postings from Xavier to   announce POSIX threads in  his Linux
Threads lib revision 0.4  in comp.os.Linux.announce.  Sean's FAQ pointed out
that this  two newsgroups might be  the best to ask   for support.  So  I am
hoping that you folks might fulfill an old wish from me.

I am using Linux-2.0.21  in combination with  the debian distribution on  an
Tyan PPRO200 dual processor board and my own distribution of X11R6.1. So far
everything ist fine. But until the last  version of Xavier's pthread library
(I have not checked out  this current version) this  library was not able to
work together with the pthread  support of X11R6 and  up. The same  problems
happens to the Linux libc.

Since many years I am an user of Solaris2 Sparc-stations and nearly every os
release was  able the compile   X11R6 with threaded    support for the  that
platform.

Do you know of a Linux POSIX thread patch for the libX11 source tree ?

This patch would make the work around pthreads  very useful for all Linux-MP
users. Most if not   all of them  would  like to use   a version of a  multi
threaded X (IMHO). And X11R6 is prepared for pthreads by  the folks from the
mit and x.org.

As far as    I could see,  the  problem  depends on  two   missing structure
definitions in xc/lib/X11/Xthread.h and xc/lib/X11/locking.c.

The gcc  compiler told me that there  are in xc/lib/X11/Xthread.h some wrong
definitions for xmutex_init() and xcondition_int().

They seems to be incompatible with the official Linux libc versions.  And as
ar as I understand Xaviers's  lib, that lib is  just  a 100% compatible  but
more efficient designed clone of the Linux libc POSIX-threads.

So his lib ends up in the same problem  while compiling locking.c for libX11
the last time when I have tried to compile a threaded X11R6.1 distribution.

Do you know how to make xmutex_init() and xcondition_int() working, in a way
that    they do     not    interact   with    pthread_muteattr_default   and
pthread_condattr_default ?

From  my point of view  (I  am not a good  C  programmer)  there could be  a
solution for  this  problem if  someone  patches  the  code  to  install the
structures pthread_mutexattr_t and  pthread_condattr_t  as  working function
parameter. And all the problems  seems to be  concentrated in one header and
one source file.

Maybe there need to be  some more structures depending on pthread_mutex_attr
or pthread_cond_attr at least.  But  I was not  able tho analyze more of the
internal code structures.

Are you a X11 ore C guru, wizard or specialist and  are be able to solve the
problems in locking.c ?

I would like to help as good as I can.  Do you have access to the X11 source
code ?

I  would spend several  cans of  virtual beers  to such a  folk. Without any
joke: Such a fix would me 25$ be worth to pay.  But not much more, because I
am not swimming in my money :-) Just a way to say thank you.

--
   Freundliche Gr?e,
   Best regards,

   Michael Hhne

 ==================================== Michael Hhne
 =    ____                          = Lt. technische Vertriebsuntersttzung

 =  /----  /   /  /   /  /___/  /   = EUnet Deutschland GmbH
 = /____  /___/  /   /  /___   /    = Emil-Figge-Str. 80
 ===                              === D-44227 Dortmund Germany
 === Connecting Europe since 1982 === Tel.: +49/231/972-1071 Fax.: -1122

 #include <disclaimer.h>

 
 
 

Linux posix threads and X11R6's thread interface

Post by Sean Walt » Thu, 10 Oct 1996 04:00:00


: Do you know of a Linux POSIX thread patch for the libX11 source tree ?

I'm sorry I can't help you here.  I understand that pThreads (Provenzano
Threads) is now included in libc.  However, it is only user-space.

-Sean Walton
PS. My latest Threads-FAQ is dated 9-Oct-96.  Would that help?

 
 
 

Linux posix threads and X11R6's thread interface

Post by Thomas Hille » Fri, 11 Oct 1996 04:00:00



I've succeeded to made fresco work with MIT pthreads a few day ago.

My platform is

kernel: 1.3.28
libc:   5.2.9 with pthreads 1.60 beta2

(1) Threaded Xlib

  (1-a) add these lines to `site.def'

#define HasPosixThreads YES
#define ProjectThreadsDefines   -D_MIT_POSIX_THREADS -DXTHREADS \
                                -D_POSIX_THREAD_SAFE_FUNCTIONS
#define ThreadsLibraries        -lpthread

  (1-b) apply below patch to `Xthreads.h'

--- cut here --- cut here --- cut here --- cut here --- cut here ---
diff -ru -x Makefile* -x *.o ./XFree86-3.1.2.orig/xc/include/Xthreads.h
./XFree86-3.1.2/xc/include/Xthreads.h
--- ./XFree86-3.1.2.orig/xc/include/Xthreads.h  Sun Jul 23 15:47:24 1995

 #define xmutex_clear(m) pthread_mutex_destroy(m)
 #define xmutex_lock(m) pthread_mutex_lock(m)
 #define xmutex_unlock(m) pthread_mutex_unlock(m)
+#ifdef _MIT_POSIX_THREADS
+#define xthread_fork(func,closure) { pthread_t _tmpxthr; \
+       pthread_create(&_tmpxthr,NULL,func,closure); }
+#define xmutex_init(m) pthread_mutex_init(m, NULL)
+#define xcondition_init(c) pthread_cond_init(c, NULL)
+#else /* _MIT_POSIX_THREADS */
 #ifndef POSIX_DRAFT7_THREADS
 #define xthread_fork(func,closure) { pthread_t _tmpxthr; \

 #define xcondition_init(c) \
        pthread_cond_init(c, &pthread_condattr_default)
 #endif /* POSIX_DRAFT7_THREADS */
+#endif /* _MIT_POSIX_THREADS */
 #define xcondition_clear(c) pthread_cond_destroy(c)
 #define xcondition_wait(c,m) pthread_cond_wait(c,m)
 #define xcondition_signal(c) pthread_cond_signal(c)
--- cut here --- cut here --- cut here --- cut here --- cut here ---

So far the summary.
I hope, that this is a starting point.
(I haven't tried it myself so far)

Greetings

--

TU Hamburg-Harburg
Zentrallabor Informations- und Kommunikationstechnik
Harburger Schloss-Str. 20               Tel.: +49-40-7718-3448
D - 21071 Hamburg                       Fax : +49-40-7718-2579

 
 
 

Linux posix threads and X11R6's thread interface

Post by Amos Shapir » Thu, 17 Oct 1996 04:00:00



> : Do you know of a Linux POSIX thread patch for the libX11 source tree ?

> I'm sorry I can't help you here.  I understand that pThreads (Provenzano
> Threads) is now included in libc.  However, it is only user-space.

> -Sean Walton
> PS. My latest Threads-FAQ is dated 9-Oct-96.  Would that help?

Does anyone know why are the user-level threads included in the
standard libc, while Kernel-level threads are available?  It's a real
drawback that I can't install the kernel-level threads package on my
Debian machine without conflicting with libc.

Cheers,

--Amos

--Amos Shapira                  | "Of course Australia was marked for
                                |  glory, for its people had been chosen

                                |                         -- Anonymous

 
 
 

Linux posix threads and X11R6's thread interface

Post by Ulrich Drepp » Thu, 17 Oct 1996 04:00:00



> Does anyone know why are the user-level threads included in the
> standard libc, while Kernel-level threads are available?  It's a real
> drawback that I can't install the kernel-level threads package on my
> Debian machine without conflicting with libc.

GNU libc will come with Xavier Leroy's LinuxThread package.  I don't
plan to use Chris' nor DCE thread packages.

--
-- Uli

Ulrich Drepper \    ,--------------------'   \  76149 Karlsruhe/Germany

 
 
 

Linux posix threads and X11R6's thread interface

Post by Alligator Descart » Mon, 21 Oct 1996 04:00:00




Quote:

>Do you know of a Linux POSIX thread patch for the libX11 source tree ?

>This patch would make the work around pthreads  very useful for all Linux-MP
>users. Most if not   all of them  would  like to use   a version of a  multi
>threaded X (IMHO). And X11R6 is prepared for pthreads by  the folks from the
>mit and x.org.

>As far as    I could see,  the  problem  depends on  two   missing structure
>definitions in xc/lib/X11/Xthread.h and xc/lib/X11/locking.c.

>Do you know how to make xmutex_init() and xcondition_int() working, in a way
>that    they do     not    interact   with    pthread_muteattr_default   and
>pthread_condattr_default ?

>From  my point of view  (I  am not a good  C  programmer)  there could be  a
>solution for  this  problem if  someone  patches  the  code  to  install the
>structures pthread_mutexattr_t and  pthread_condattr_t  as  working function
>parameter. And all the problems  seems to be  concentrated in one header and
>one source file.

Hi there. Compiling multi-thread safe X under Linux with LinuxThreads was
a complete breeze.

Of course, I've since deleted my copy of the patches. 8-( As far as I can
remember, you need to define the following symbols in the config file:

        HAS_POSIX_THREADS
        XTHREADS
        _REENTRANT
        _MIT_POSIX_THREADS
        POSIX_DRAFT7_THREADS

which seems to make things behave a bit better. Adding pthread_condattr_default
is quite simple. Just create a structure:

        struct pthread_condattr_t pthread_condattr_default

and do the same for pthread_mutexattr_default, and it should compile
reasonably cleanly.

The main caveat is altering the Makefiles to generate libraries called, eg,
'libpX11' and 'libpXt' instead of libX11, for testing purposes. You don't want
to link with the standard X libraries on building stuff like libXaw.

Good luck! I can email you compiled X11 libraries if you like. Let me know.

A.

--
Alligator Descartes                                             Anathematician

http://www.hermetica.com                                        KEPhALH F