* Problem with Posix thread library
@ 1996-05-21 4:00 Deryk Barker
1996-05-22 4:00 ` Burkhard Neidecker-Lutz
0 siblings, 1 reply; 5+ messages in thread
From: Deryk Barker @ 1996-05-21 4:00 UTC (permalink / raw)
Has anyone had any luck getting the pthreads library to run under
Digital Unix on an Alpha?
I have a brief test program (culled from the Sun Solaris man page
example) which works just fine on a SPARC under Solaris 2.5 but gets a
segmentation fault on the Alpha.
Any help would be appreciated.
Code and error message follow.
--
Deryk.
===========================================================================
|Deryk Barker, Computer Science Dept. | Across the pale parabola of Joy |
|Camosun College, Victoria, BC, Canada | |
|email: dbarker@camosun.bc.ca | Ralston McTodd |
|phone: +1 604 370 4452 | (Songs of Squalor). |
===========================================================================
#include <stdio.h>
#include <pthread.h>
#define NUM_THREADS 5
#define SLEEP_TIME 10
void *sleeping(void *); /* thread routine */
int i;
pthread_t tid[NUM_THREADS]; /* array of thread IDs */
main (int argc, char *argv[]){
for (i = 0; i < NUM_THREADS; i++)
pthread_create(&tid[i], pthread_attr_default, sleeping, &i);
/* pthread_attr_default is NULL in the Solaris version, but this gives
a warning on the Alpha
*/
for (i = 0; i < NUM_THREADS; i++)
pthread_join(tid[i], NULL);
printf("main() reporting that all %d threads have terminated\n", i);
} /* main */
void *sleeping (void *sleep_time){
printf("thread %d sleeping %d seconds ...\n", pthread_self(), SLEEP_TIME);
sleep (10);
printf("\nthread %d awakening\n", pthread_self());
}
Run from the shell this simply seg faults.
When run under dbx I get the following message:
signal Segmentation fault at >*[port_allocate, 0x3ff82008f5c] stq r26, 0(sp)
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Problem with Posix thread library
1996-05-21 4:00 Problem with Posix thread library Deryk Barker
@ 1996-05-22 4:00 ` Burkhard Neidecker-Lutz
1996-05-22 4:00 ` Charles M.Richmond
0 siblings, 1 reply; 5+ messages in thread
From: Burkhard Neidecker-Lutz @ 1996-05-22 4:00 UTC (permalink / raw)
In article <4nt7ij$jdh@news.camosun.bc.ca> dbarker@camosun.bc.ca (Deryk Barker) writes:
>Has anyone had any luck getting the pthreads library to run under
>Digital Unix on an Alpha?
Yes...
>I have a brief test program (culled from the Sun Solaris man page
>example) which works just fine on a SPARC under Solaris 2.5 but gets a
>segmentation fault on the Alpha.
<code deleted>
You probably didn't compile it correctly. Try:
c89 -threads threadexample.c -o threadexample
Manually specifying the libraries is tricky and likely gives you the
wrong versions of some of the headers and libraries. For details add
a "-v" to the C compiler flags to see what it really does.
% uname -a
OSF1 glass.kar.dec.com V3.2 41 alpha
% c89 -threads threadexample.c -o threadexample
% ./threadexample
thread 293912 sleeping 2 seconds ...
thread 291864 sleeping 4 seconds ...
thread 290840 sleeping 5 seconds ...
thread 292888 sleeping 3 seconds ...
thread 289816 sleeping 6 seconds ...
thread 293912 awakening
thread 291864 awakening
thread 292888 awakening
thread 290840 awakening
thread 289816 awakening
main() reporting that all 5 threads have terminated
Burkhard Neidecker-Lutz
EUROMEDIA - Distributed Multimedia Archives for Cooperative TV Production
CEC Karlsruhe , European Applied Research Center, Digital Equip. Corp.
email: neideck@kar.dec.com
"May 96: 4xAlphaServer 8400 5/350, Unix TruCluster, Oracle: 30,390 tpmC@$305"
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Problem with Posix thread library
1996-05-22 4:00 ` Burkhard Neidecker-Lutz
@ 1996-05-22 4:00 ` Charles M.Richmond
0 siblings, 0 replies; 5+ messages in thread
From: Charles M.Richmond @ 1996-05-22 4:00 UTC (permalink / raw)
Burkhard Neidecker-Lutz wrote:
>
> In article <4nt7ij$jdh@news.camosun.bc.ca> dbarker@camosun.bc.ca (Deryk Barker) writes:
> >Has anyone had any luck getting the pthreads library to run under
> >Digital Unix on an Alpha?
>
> Yes...
>
> >I have a brief test program (culled from the Sun Solaris man page
> >example) which works just fine on a SPARC under Solaris 2.5 but gets a
> >segmentation fault on the Alpha.
>
> <code deleted>
>
> You probably didn't compile it correctly. Try:
>
> c89 -threads threadexample.c -o threadexample
>
> Manually specifying the libraries is tricky and likely gives you the
> wrong versions of some of the headers and libraries. For details add
> a "-v" to the C compiler flags to see what it really does.
>
> % uname -a
> OSF1 glass.kar.dec.com V3.2 41 alpha
> % c89 -threads threadexample.c -o threadexample
> % ./threadexample
> thread 293912 sleeping 2 seconds ...
> thread 291864 sleeping 4 seconds ...
> thread 290840 sleeping 5 seconds ...
> thread 292888 sleeping 3 seconds ...
> thread 289816 sleeping 6 seconds ...
>
> thread 293912 awakening
>
> thread 291864 awakening
>
> thread 292888 awakening
>
> thread 290840 awakening
>
> thread 289816 awakening
> main() reporting that all 5 threads have terminated
>
> Burkhard Neidecker-Lutz
>
> EUROMEDIA - Distributed Multimedia Archives for Cooperative TV Production
> CEC Karlsruhe , European Applied Research Center, Digital Equip. Corp.
> email: neideck@kar.dec.com
> "May 96: 4xAlphaServer 8400 5/350, Unix TruCluster, Oracle: 30,390 tpmC@$305"
You are absolutely correct and c89 is not necessary. The following
worked for me:
koibito.iisc.com> cc -threads -g -o ts ts.c
koibito.iisc.com> ts
thread 291864 sleeping 4 seconds ...
thread 289816 sleeping 6 seconds ...
thread 290840 sleeping 5 seconds ...
thread 293912 sleeping 2 seconds ...
thread 292888 sleeping 3 seconds ...
thread 291864 awakening
thread 289816 awakening
thread 290840 awakening
thread 293912 awakening
thread 292888 awakening
main() reporting that all 5 threads have terminated
--
*************************************************************************
* Charles Richmond Integrated International Systems Corporation *
* cmr@iisc.com cmr@koibito.iisc.com cmr@shore.net *
* UNIX Internals, I18N, L10N, X, Realtime Imaging, and Custom S/W *
* One Longfellow Place Suite 3309 , Boston , Ma. USA 02114-2431 *
* (617) 723 7695 (617) 367 3151 FAX (617) 723 6861 *
*************************************************************************
^ permalink raw reply [flat|nested] 5+ messages in thread
* re: problem with posix thread library
@ 1996-05-22 4:00 sean levy
1996-05-23 4:00 ` Burkhard Neidecker-Lutz
0 siblings, 1 reply; 5+ messages in thread
From: sean levy @ 1996-05-22 4:00 UTC (permalink / raw)
Deryk Barker wrote:
>
> Has anyone had any luck getting the pthreads library to run under
> Digital Unix on an Alpha?
[snip snip]
> void *sleeping (void *sleep_time){
> printf("thread %d sleeping %d seconds ...\n", pthread_self(), SLEEP_TIME);
^^ ^^^^^^^^^^^^^^
> sleep (10);
> printf("\nthread %d awakening\n", pthread_self());
^^ ^^^^^^^^^^^^^^
> }
>
under osf/1 [at least as of 3.2c, which is what i'm running] pthread_t is
a struct, not a pointer or integer. this is the worst of the interface
incompatibilities between dec's implementation and all others i've seen
so far, which don't hand structures around by value.
cheers,
--sean
--
sean levy, sr. research programmer, n-dim group, edrc, carnegie mellon univ.
<snl+@cmu.edu> | http://paneer.ndim.edrc.cmu.edu/Home/snl | +1 412 268 5215
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: problem with posix thread library
1996-05-22 4:00 problem with posix " sean levy
@ 1996-05-23 4:00 ` Burkhard Neidecker-Lutz
0 siblings, 0 replies; 5+ messages in thread
From: Burkhard Neidecker-Lutz @ 1996-05-23 4:00 UTC (permalink / raw)
In article <31A3591A.41C6@paneer.ndim.edrc.cmu.edu> sean levy <snl@paneer.ndim.edrc.cmu.edu> writes:
>under osf/1 [at least as of 3.2c, which is what i'm running] pthread_t is
>a struct, not a pointer or integer. this is the worst of the interface
>incompatibilities between dec's implementation and all others i've seen
>so far, which don't hand structures around by value.
That's because we introduced POSIX threads very early and hence were
based on an early draft of the standard (draft 4). In Digital UNIX V4.0
you get the 1003.1C interfaces and pthread_t is a pointer.
Burkhard Neidecker-Lutz
EUROMEDIA - Distributed Multimedia Archives for Cooperative TV Production
CEC Karlsruhe , European Applied Research Center, Digital Equip. Corp.
email: neideck@kar.dec.com
"PA-8000 users: send me mail when you get one delivered. Current count: n/a"
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1996-05-23 4:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-05-21 4:00 Problem with Posix thread library Deryk Barker
1996-05-22 4:00 ` Burkhard Neidecker-Lutz
1996-05-22 4:00 ` Charles M.Richmond
-- strict thread matches above, loose matches on Subject: below --
1996-05-22 4:00 problem with posix " sean levy
1996-05-23 4:00 ` Burkhard Neidecker-Lutz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox