From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: ffc1e,eab943a190c40eeb X-Google-Attributes: gidffc1e,public X-Google-Thread: f678f,eab943a190c40eeb X-Google-Attributes: gidf678f,public X-Google-Thread: fee84,eab943a190c40eeb X-Google-Attributes: gidfee84,public From: Dave Butenhof Subject: Re: PthreadD4 problem under OSF/1 3.0b Date: 1996/04/17 Message-ID: <3174D227.52BF@zko.dec.com>#1/1 X-Deja-AN: 148159329 references: content-type: text/plain; charset=us-ascii organization: Digital Equipment Corporation mime-version: 1.0 newsgroups: comp.programming.threads,comp.unix.osf.osf1,comp.unix.osf.misc x-mailer: Mozilla 2.01 (X11; I; OSF1 V4.0 alpha) Byron K Guernsey wrote: > > I wrote a program which spawns threads for TCP connections and the parent > immediately does a pthread_detach() to allow the threads to die without having > to babysit. > > It appears to work fine. However, I used the dbx debugger to attach to the > process and do a tlist to see what threads were running when no threads should > be running. It listed 3 threads running, the parent which was in an accept and > two children who logged as exited correctly in the log file. The 2 threads > had already called pthread_exit() but were waiting in some routine named > ???_rpc_msg. I'm positive that I am detaching from them after I create them, > and if I understood correctly they should be able to exit and cleanup after > that is done? Why then does the debugger show these lying in wait? > > Byron > The kernel threads were CACHED by the thread library for re-use -- it's "relatively expensive" to create a new kernel thread, so they're kept around. Since dbx is showing you only the kernel threads (dbx knows nothing about user thread context -- you have to switch to ladebug for that), you still see them even though they're gone. The message receive call is just a Mach primitive that happens to be the mechanism used to block the kernel thread until it's needed again. +-------------------------------------------------------------------+ | Dave Butenhof Digital Equipment Corporation | | butenhof@zko.dec.com 110 Spit Brook Rd, ZKO2-3/Q18 | | PH 603.881.2218, FAX 603.881.0120 Nashua, NH 03062-2711 | +----------+ "Better Living Through Concurrency" +----------+ +---------------------------------------------+