From: Dave Butenhof <butenhof@zko.dec.com>
Subject: Re: Dec Unix 4.0B and threads
Date: 1997/05/05 [thread overview]
Message-ID: <336DBA10.6102@zko.dec.com> (raw)
In-Reply-To: 5kb3ip$jqt@shellx.best.com
Dilip Dasilva wrote:
>
> Hi,
>
> I am trying to compile a program that uses threads on Dec Unix 4.0B
> that compiled without a problem on Dec Unix 3.2.
>
> It uses posix threads so I have the following include file
>
> #include <pthread.h>
>
> The problem is that these files are different between 4.0B and 3.2.
> The 4.0B file does not contain the definitions for pthread_startroutine_t
> and pthread__addr_t . These definitions are included in
> /usr/include/pthread_exc.h. I noticed that there are two pthread.h
> include files - one in /usr/include/pthread.h and the other in
> /usr/include/dce/pthread.h . On 3.2 one of these files was
> a linked to the other.
DEC OSF/1 3.2 did not have POSIX threads. It had "DCE threads", a
partial implementation of the ancient and obsolete DRAFT 4 of the
document that would eventually evolve into the POSIX standard. Draft 4
would have been forgotten (and deservedly so) in December of 1990, when
it was superceded by draft 5 -- except that the Open Software Foundation
wanted "standard" threads for DCE and chose unwisely to use something
that WASN'T a standard to meet that desire.
Artifacts like pthread_addr_t and pthread_startroutine_t are worse,
since they're not even from the draft standard -- they're pure DCE
thread hacks. In fact, the exist only because we had to deal with old,
non-ANSI C compilers, (as well as some buggy compilers that claimed to
support ANSI C), that didn't work well with "void *". The pseudo-type
pthread_addr_t is nothing more than "void *", and pthread_startroutine_t
is just "void *(*)(void*)". Except that, on platforms where that would
have been unacceptable to the compiler (and now, over 6 years later,
there should no longer be any such archaic compilers!), the headers
would substitute "char *" for "void *". The private DCE types hid that
messiness.
> Does anyone know which include files I need to get my program to
> compile on 4.0B.
The fact that your code isn't building on 4.0 almost certainly means
that you were building incorrectly on 3.2. You should be compiling and
linking using "cc -threads". That was the only supported way to build
threaded code on 3.2, and had you used it you'd have seen no change on
4.0. But if you're intent on doing it yourself, on 4.0 you need to add
the definition -D_PTHREAD_USE_D4 to the cc command. (Of course you're
already compiling with -D_REENTRANT and linking with "-lpthreads -lmach
-lc_r" at the end of the list of libraries and in exactly that order,
right? Now, to link DCE thread code on 4.0, you need to use "-lpthreads
-lpthread -lmach -lexc", in exactly that order.)
The root of the problem is that OSF chose to illicitly use a draft
standard as if it were a real standard. Inevitably, the standard
changed, and OSF didn't. We've tried to provide as much compatibility
for Digital UNIX 4.0 as possible, but we're limited by the reality that
DCE threads isn't, and never was, a standard, and POSIX threads IS a
standard. Where they conflict (and that's MANY places, including the
name of the header file), POSIX threads IS the only rule, and we will
not sacrifice POSIX conformance for DCE hackery.
The pthread_exc.h header, by the way, is something else entirely -- it
defines a variant of the DCE thread interfaces that report all errors by
raising exceptions rather than by returning error numbers (as in POSIX
threads) or setting errno and returning -1 (as in DCE threads). This is
the interface that was used by most DCE code, since exceptions are a
much more reliable way to deal with errors in threaded code. That's
pretty much unchanged, since POSIX threads has no pthread_exc.h. The
definitions for the "pseudo-standard" DCE thread interfaces have been
relegated to /usr/include/dce/pthread_d4.h. Including <pthread.h>,
however, with _PTHREAD_USE_D4 defined, will "chain" to
<dce/pthread_d4.h>, defining a compatible DCE thread environment,
including pthread_addr_t and pthread_startroutine_t.
/---[ Dave Butenhof ]-----------------------[ butenhof@zko.dec.com ]---\
| Digital Equipment Corporation 110 Spit Brook Rd ZKO2-3/Q18 |
| 603.881.2218, FAX 603.881.0120 Nashua NH 03062-2698 |
\-----------------[ Better Living Through Concurrency ]----------------/
next prev parent reply other threads:[~1997-05-05 4:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-05-01 4:00 Dec Unix 4.0B and threads Dilip Dasilva
1997-05-02 4:00 ` Chris Cebelenski
1997-05-02 4:00 ` Peter Sanger
1997-05-05 4:00 ` Dave Butenhof [this message]
1997-05-05 4:00 ` Brian O'Neill
1997-05-06 4:00 ` Peter Sanger
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox