From: rsalz@osf.org (Rich Salz)
Subject: Re: HELP: Question on DCE Threads
Date: 9 Nov 1994 13:26:24 GMT [thread overview]
Message-ID: <39qim0$9fv@paperboy.osf.org> (raw)
In-Reply-To: androidCyC7rD.MKv@netcom.com
In <androidCyC7rD.MKv@netcom.com> android@netcom.com (Pramod Kalapa) writes:
> if((pthread_create(&thread_hdl1, pthread_attr_default,
> (pthread_startroutine_t) open_file,
> (pthread_addr_t)NULL)) != 0)
>However, the thread doesn't enter the function "open_file". I've stepped
>through the code with dbx and it just exits out of main.
Just to clarify, the thread that called pthread_create doesn't enter
open_file. Instead a new "flow of execution" starts. If your
main is doing
pthread_create
pthread_create
exit
Then what is probably happening is that the three threads are running
just before exit, but then they're all shut down by the process exit.
You probably want to put
pthread_join(&thread_hdl1);
pthread_join(&thread_hdl2);
before your call to exit. This will make sure that your process doesn't
go away until all the threads are finished.
As a side note, very few debuggers are aware of threads. I don't know
about AIX's dbx (this is also an inside joke :-). You might find it
easier to do something like
if((pthread_create(&thread_hdl1, pthread_attr_default,
open_file, "#1")) != 0)
if((pthread_create(&thread_hdl2, pthread_attr_default,
open_file, "#2")) != 0)
And write open_file as
void *open_file(void *arg) {
if (debugging && arg != NULL) {
fprintf(stderr, "open_file %s started\n", (char *)arg);
fflush(stderr);
}
... real body of the thread ...
}
prev parent reply other threads:[~1994-11-09 13:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1994-10-27 15:16 HELP: Question on DCE Threads Pramod Kalapa
1994-10-27 22:26 ` Miles_Krivoshia
1994-10-28 17:24 ` Brad Daniels
1994-10-31 14:37 ` Paul Roberts
1994-11-09 13:26 ` Rich Salz [this message]
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