* pthreads
@ 2000-04-26 4:00 Harish
2000-04-26 4:00 ` pthreads Fred Zwarts
0 siblings, 1 reply; 6+ messages in thread
From: Harish @ 2000-04-26 4:00 UTC (permalink / raw)
Hi,
I would like to know if it is possible to port a code which uses
pthreads to OSF1 V4.0 alpha ?
I have an application in which I include pthread.h. I am able to
compile and run this application successfully on Linux, SunOS and
OpenBSD. I would like to port this also to OSF1. Is this possible ?
Some error that I get
In file included from /usr/local/lib/gcc-lib/alpha-dec-osf4.0d/2.8.1/
include/pthread.h:333,
from app.c:282:
/usr/include/c_asm.h:193: parse error before `asm'
Thanks
- Harish
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: pthreads
2000-04-26 4:00 pthreads Harish
@ 2000-04-26 4:00 ` Fred Zwarts
2000-04-26 4:00 ` pthreads Harish
0 siblings, 1 reply; 6+ messages in thread
From: Fred Zwarts @ 2000-04-26 4:00 UTC (permalink / raw)
"Harish" <harish@ukans.edu> wrote in message news:8e63fa$d6k$1@news.cc.ukans.edu...
> Hi,
>
> I would like to know if it is possible to port a code which uses
> pthreads to OSF1 V4.0 alpha ?
>
> I have an application in which I include pthread.h. I am able to
> compile and run this application successfully on Linux, SunOS and
> OpenBSD. I would like to port this also to OSF1. Is this possible ?
>
> Some error that I get
>
> In file included from /usr/local/lib/gcc-lib/alpha-dec-osf4.0d/2.8.1/
> include/pthread.h:333,
> from app.c:282:
> /usr/include/c_asm.h:193: parse error before `asm'
>
> Thanks
>
> - Harish
>
Yes, I use pthreads. Do you use the correct compiler flags?
I compile with
cc -pthread -std1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: pthreads
2000-04-26 4:00 ` pthreads Fred Zwarts
@ 2000-04-26 4:00 ` Harish
2000-04-26 4:00 ` pthreads Steffen Neumann
0 siblings, 1 reply; 6+ messages in thread
From: Harish @ 2000-04-26 4:00 UTC (permalink / raw)
Hi,
: Yes, I use pthreads. Do you use the correct compiler flags?
: I compile with
: cc -pthread -std1
Thanks for your reply. I need to use gcc for compilation. The flags
that I did try were
-D_REENTRANT -D_PTHREAD_USE_D4 -lpthread -lmach -lexc
though I think these are specific to DEC threads. So, wouldn't
something like this
gcc -c app.c -o app.o -lpthread
work ? It seems to give the error that I mentioned in the previous
posting.
- Harish
^ permalink raw reply [flat|nested] 6+ messages in thread
* pthreads
@ 1994-02-11 18:17 Markus Klingspor
1994-02-14 16:56 ` pthreads Simon Patience
0 siblings, 1 reply; 6+ messages in thread
From: Markus Klingspor @ 1994-02-11 18:17 UTC (permalink / raw)
I'm looking for a working example how to create at least one thread using
pthread_create.
- Markus Klingspor
+------------------------------------------------------------------------------+
| This signature is generated automatically and is valid without any signature |
+------------------------------------------------------------------------------+
| Markus Klingspor |
| Lehrstuhl f"ur Informatik II Tel.: (0931 888) 5855 |
| Universit"at W"urzburg Fax: (0931 888) 4602 |
| Am Hubland |
| 97074 W"urzburg Mail: klingspo@informatik.uni-wuerzburg.de|
+------------------------------------------------------------------------------+
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: pthreads
1994-02-11 18:17 pthreads Markus Klingspor
@ 1994-02-14 16:56 ` Simon Patience
0 siblings, 0 replies; 6+ messages in thread
From: Simon Patience @ 1994-02-14 16:56 UTC (permalink / raw)
In article <2jgi3o$999@winx03.informatik.uni-wuerzburg.de>, klingspo@informatik.uni-wuerzburg.de (Markus Klingspor) writes:
> I'm looking for a working example how to create at least one thread using
> pthread_create.
This program was written to 1003.4a Draft 4. When you run it, give it the
number of threads you want to create. On OSF/1, remember to link using
-lpthreads -lmach -lc_r
in that order.
Enjoy
Simon.
---cut here---cut here---cut here---cut here---cut here---cut here---cut here---
#include <pthread.h>
#include <stdio.h>
int count = 0;
pthread_mutex_t lock;
pthread_cond_t done;
typedef struct slave_struct {
char name[10];
int count;
} *slave_info_t;
void *
slave(void *arg)
{
slave_info_t info;
int i;
info = (slave_info_t)arg;
for (i = 0; i < info->count; i++)
pthread_yield();
pthread_mutex_lock(&lock);
count--;
printf("%s finished %d cycles\n", info->name, info->count);
free(info);
pthread_mutex_unlock(&lock);
pthread_cond_signal(&done);
}
void *
master(nslaves)
int nslaves;
{
int i;
pthread_t new_thread;
slave_info_t slaveinfo;
for (i = 1; i <= nslaves; i++) {
slaveinfo = (slave_info_t)malloc(sizeof(struct slave_struct));
sprintf(slaveinfo->name, "slave%d", i);
slaveinfo->count = random()%1000;
pthread_mutex_lock(&lock);
count++;
pthread_create(&new_thread, pthread_attr_default,
slave, (void *)slaveinfo);
pthread_detach(&new_thread);
pthread_mutex_unlock(&lock);
}
pthread_yield();
pthread_mutex_lock(&lock);
while (count != 0)
pthread_cond_wait(&done, &lock);
pthread_mutex_unlock(&lock);
printf("All %d slaves have finished\n", nslaves);
return((void *)nslaves);
}
void
main(argc, argv)
int argc;
char **argv;
{
pthread_t new_thread;
void *status;
int ntimes;
if (argc != 2) {
printf("usage: master loop_count\n");
exit(1);
}
pthread_mutex_init(&lock, pthread_mutexattr_default);
pthread_cond_init(&done, pthread_condattr_default);
ntimes = atoi(argv[1]);
pthread_create(&new_thread, pthread_attr_default, master, (void *)ntimes);
if (pthread_join(new_thread, &status) != 0) {
perror("main_join");
exit(1);
}
printf("master exited with status = %d\n", status);
pthread_detach(&new_thread);
pthread_exit(0);
}
---cut here---cut here---cut here---cut here---cut here---cut here---cut here---
--
Simon Patience Phone: (617) 621-7376
Open Software Foundation FAX: (617) 621-8696
1 Cambridge Center Email: sp@osf.org
Cambridge, MA 02142 uunet!osf!sp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2000-04-26 4:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-04-26 4:00 pthreads Harish
2000-04-26 4:00 ` pthreads Fred Zwarts
2000-04-26 4:00 ` pthreads Harish
2000-04-26 4:00 ` pthreads Steffen Neumann
-- strict thread matches above, loose matches on Subject: below --
1994-02-11 18:17 pthreads Markus Klingspor
1994-02-14 16:56 ` pthreads Simon Patience
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox