From: Dong Liu <dliu@npiww.com>
To: ralf@uni-koblenz.de
Cc: linux@cthulhu.engr.sgi.com
Subject: Re: glibc problem
Date: Tue, 28 Apr 1998 15:11:31 -0400 [thread overview]
Message-ID: <199804281911.PAA09285@pluto.npiww.com> (raw)
In-Reply-To: <19980428013350.27295@uni-koblenz.de>
ralf@uni-koblenz.de writes:
> On Mon, Apr 27, 1998 at 07:37:42PM -0400, Dong Liu wrote:
>
> > Sorry, I didn't install it properly, now my program links, but it
> > still give segementation fault.
>
> Ok. I have to admit that I never tested any kind of multithread application.
> If you could provide the code for the program in question, that'd be
> helpful.
>
> Ralf
>
How about this
---- create-thread.c----
#include <pthread.h>
#include <stdio.h>
void* new_thread(void* arg)
{
int i;
printf("Thread[%s] stack at %x\n",arg, &i);
for (i = 0; i< 4; i++) {
printf("Thread[%s] %d\n", arg, i);
sched_yield();
}
return(NULL);
}
#define NUM_OF_THREAD 100
main(int argc, char **argv)
{
int num = NUM_OF_THREAD;
pthread_t thread[NUM_OF_THREAD];
char *args[NUM_OF_THREAD];
int i;
int last;
void *status;
if (argc > 1)
num = atoi(argv[1]);
if (num>100)
num = 100;
printf("Original thread stack at %x\n", &i);
for (i = 0 ; i < num; i++) {
args[i] = (char *)malloc(80);
sprintf(args[i], "%04d", i);
if (pthread_create(&thread[i],
NULL,
new_thread, (void *)args[i])) {
printf("Error: creating new thread[%d]\n", i);
break;
}
}
last = i;
for (i = 0 ; i < last; i++) {
pthread_join(thread[i], &status);
printf("thread[%d] return status' address %p\n",i, status);
}
printf("%d threads created\n", last);
exit(0);
}
next prev parent reply other threads:[~1998-04-28 18:56 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-04-22 21:19 glibc problem Dong Liu
1998-04-22 21:13 ` Alex deVries
1998-04-22 21:43 ` ralf
1998-04-23 2:23 ` Alex deVries
1998-04-23 3:17 ` ralf
1998-04-23 3:28 ` Alex deVries
1998-04-22 21:48 ` Dong Liu
1998-04-23 3:04 ` ralf
1998-04-24 16:00 ` Dong Liu
1998-04-27 23:37 ` Dong Liu
1998-04-27 23:33 ` ralf
1998-04-28 19:11 ` Dong Liu [this message]
-- strict thread matches above, loose matches on Subject: below --
1998-04-22 23:24 Dong Liu
2000-10-25 15:06 Glibc Problem Ian Chilton
2000-10-25 15:45 ` Keith M Wesolowski
2000-10-25 15:54 ` Andreas Jaeger
2001-07-26 9:09 glibc problem Andre.Messerschmidt
2001-07-26 13:46 ` Ralf Baechle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199804281911.PAA09285@pluto.npiww.com \
--to=dliu@npiww.com \
--cc=linux@cthulhu.engr.sgi.com \
--cc=ralf@uni-koblenz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox