From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,b9c84b1914162ecd X-Google-Attributes: gidfee84,public From: Dave Butenhof Subject: Re: HOW-TO KILL THREADS Date: 1997/11/03 Message-ID: <345DCB95.48AB08DF@softtail.zko.dec.com>#1/1 X-Deja-AN: 286769555 References: <632s9v$r99$0@206.165.146.124> <3455C9DB.CDC9DE0@zko.dec.com> <34563964.6488@my.sig.for.address> <636h7d$7al$0@207.16.238.216> Organization: Digital Equipment Corporation Newsgroups: comp.unix.osf.osf1 Richard Spangenberg wrote: > > Thank you for the resonse. I know that IBM and POSIX do allow this through > the pthread_kill command. Databases like MYSQL and PostgreSQL seem to want > this capability. AIX 4.# has pthread_kill(), so IBM later noticed that the > command was needed, etc. As I said, OSF/1 3.2 didn't have POSIX threads, and therefore lacked pthread_kill -- which was added to a later draft. IBM 4.x (up through 4.3, which has POSIX threads) implemented "draft 7" of the POSIX standard: not quite as archaic as draft 4 (on which DCE threads was based), but still a long way from POSIX threads. The question of whether pthread_kill exists or not, however, has no bearing on the main point of my message, which is that killing a misbehaving thread is NOT, in general, going to leave the process in a reliable (or predictable) state. However, as established in private mail, (and for the benefit of other readers who weren't party to those messages!), it turns out that the problem was misstated. Richard is NOT trying to kill randomly "stuck" threads. Rather, they know that the thread is blocked in a syscall, (e.g., reading from a socket), and wish to abort that syscall so the thread can voluntarily process an "abort" request (a flag set in shared state). The pthread_kill function is just fine for that case. It will "break through" the read, causing it to return with EINTR, after which the calling thread can check whether it ought to abort. No problem. > Your explaination sounds well informed, however, and my understanding is > only marginal. I bow to your expertise and thank you. It certainly seems > correct for dec/alpha. A correct answer to an incorrect question may nevertheless be misleading! /---------------------------[ Dave Butenhof ]--------------------------\ | Digital Equipment Corporation butenhof@zko.dec.com | | 110 Spit Brook Rd ZKO2-3/Q18 http://members.aol.com/drbutenhof | | Nashua NH 03062-2698 http://www.awl.com/cseng/titles/0-201-63392-2/ | \-----------------[ Better Living Through Concurrency ]----------------/