From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f678f,c901133e3f78f6c9 X-Google-Attributes: gidf678f,public X-Google-ArrivalTime: 1994-11-09 05:26:24 PST Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!swrinde!hookup!olivea!grapevine.lcs.mit.edu!think.com!paperboy.osf.org!rsalz From: rsalz@osf.org (Rich Salz) Newsgroups: comp.unix.osf.misc Subject: Re: HELP: Question on DCE Threads Date: 9 Nov 1994 13:26:24 GMT Organization: Open Software Foundation Message-ID: <39qim0$9fv@paperboy.osf.org> References: NNTP-Posting-Host: sulphur.osf.org Cc: In 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 ... }