Usenet comp.unix.osf.misc (1992-2004)
 help / color / mirror / Atom feed
* PthreadD4 problem under OSF/1 3.0b
@ 1996-04-15  4:00 Byron K Guernsey
  1996-04-17  4:00 ` Dave Butenhof
  0 siblings, 1 reply; 2+ messages in thread
From: Byron K Guernsey @ 1996-04-15  4:00 UTC (permalink / raw)


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

-- 
No matter what your doing,
  Someone will always be there to tell you how...



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PthreadD4 problem under OSF/1 3.0b
  1996-04-15  4:00 PthreadD4 problem under OSF/1 3.0b Byron K Guernsey
@ 1996-04-17  4:00 ` Dave Butenhof
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Butenhof @ 1996-04-17  4:00 UTC (permalink / raw)


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"     +----------+
           +---------------------------------------------+



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1996-04-17  4:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-04-15  4:00 PthreadD4 problem under OSF/1 3.0b Byron K Guernsey
1996-04-17  4:00 ` Dave Butenhof

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox