[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference clt::cma

Title:DECthreads Conference
Moderator:PTHRED::MARYSTEON
Created:Mon May 14 1990
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1553
Total number of notes:9541

1550.0. "pthread_attr_create()/pthread_setprio()" by MIASYS::CURRIER (Matt DTN 381-2595) Fri May 23 1997 16:08

Hi,
    I am placing this note on behalf of Dave Collins.
    
    			Thanks,
    
    			Matt
    -------------------------------------------------------------------
    
We have been having problems at a customer site using UNIX 4.0b and 
C++ 5.50.    The customer was attempting to port from a HP-RT platform 
to Digital UNIX and the base code include calls to:

  pthread_attr_create() and
  pthread_setprio()

These calls are documented in older Digital documentation that
referenced POSIX 1003.4a, but do not show up (no forward declarations)
in Digital 4.0 UNIX referencing POSIX 1003.1c.

 Q: Why does the older UNIX have a "higher" posix number?

The following trivial code example compiles if pthread.h is used
in place of pthread_exc.h.   Do we need to specify some POSIX defines
to make this work.   The include files that the customer is referencing
have a problem when trying to use pthread_exc.h

 #include <pthread_exc.h>
 #include <sys/types.h>
 #include <timers.h>

The reason the customer is attemptng to use pthread_exc.h is to 
use the two functions "pthread_attr_create & pthread_setprio"


#include <pthread.h>
// #include <pthread_exc.h>
#include <sys/types.h>
#include <timers.h>
#include <stdio.h>
#include <stdlib.h>

int ii;

void *start_routine (void * arg)
{
int *parg;

	parg = (int *) (arg);

	for (ii = 0; ii<*parg; ii++)

		{
		if (ii > 9999)
			break;
		}
	printf ("\n Thread ii = %d\n", ii);

	pthread_exit((void *) (&ii));

	return (void *) (NULL);
}

main()
{
pthread_t thread1;
int arg = 1256;
int ret = 55;
int *pi;

pi = &ret;
pthread_create (&thread1, NULL, &start_routine, (void *) (&arg));
pthread_join(thread1, (void **) &pi);
printf("\n Thread returned %d \n", *pi);
exit(1);

}

--------------------------------------------------

		Thanks,

		Dave Collins
		[email protected]
		
T.RTitleUserPersonal
Name
DateLines
1550.11003.4a is old and moldy.WTFN::SCALESDespair is appropriate and inevitable.Fri May 23 1997 17:3438
.0> Why does the older UNIX have a "higher" posix number?

1003.4a and 1003.1c are not version numbers (I think the pthread(3) man page
makes this clear); their relative values don't hold any particular meaning.

1003.4 is the designation for the IEEE POSIX Realtime Working Group.  1003.4a
was the designation for a subset of the group which worked on the threads
standard.  Drafts of this standard were known as 1003.4a/Dx (where "x" is the
draft number), with Draft 4 being the one which DECthreads first implemented. 
(We submitted this code to the Open Software Foundation, and it became sort of a
de facto standard...sadly.)  Somewhere around draft 10, the designation of the
threads effort was changed to 1003.1c, since the eventual standard would be
published as a modified version of 1003.1, which is the base operating system
specification (named after the working group which produced it).

Now that the standard is final, and we've released our implementation of the
final interface, we're in the process of revoking support for the old draft 4
interface.  However, on V4.0 it is still available.  If you were compiling using
the cc driver, you would specify "-threads" to get it.  (To compile/link against
the standard interface you'd specify "-pthread".)  I'm not sure exactly what
magic to recommend to you since you're using C++.  At a minimum you need to
define the symbols "_REENTRANT" and "PTHREAD_USE_D4" for your compilation, and
you need to include the following in your link, "-lpthreads -lpthread -lmach
-lexc", but it would be better if you used a special compiler switch if there is
one.

.0> The following trivial code example compiles if pthread.h is used
.0> in place of pthread_exc.h.

That's only because it's trivial (i.e., because you're lucky -- e.g., you're not
checking any status returns, something which is done differently in the two
interfaces...).

As I indicated, the support for 1003.4a/D4 is going away, so your customer would
be well advised to migrate his code to the final standard interface.


				Webb
1550.2use option -threadsBHAJEE::AIGNERMon May 26 1997 08:109
As Webb recommended, use -threads.
This option is also available for C++.
Specify it in the compile and link command, if you have to use the old style
POSIX 1003.4a/D4. It includes all the necessary defines and library
specifications you need for 1003.4a/D4.

Nevertheless try to use new POSIX 1003.1c if you can modify the existing code.

Helmut