* HOW-TO KILL THREADS @ 1997-10-27 5:00 Richard Spangenberg 1997-10-28 5:00 ` Dave Butenhof 0 siblings, 1 reply; 5+ messages in thread From: Richard Spangenberg @ 1997-10-27 5:00 UTC (permalink / raw) We are trying to install a database (MYSQL) in a Dec/ALpha OSF1 3.2 machine. Everything is up and running but we are concerned that there appears to be do way to stop a thread if it starts to eat up CPU time. The problem is that pthread_kill doesn't exits. Is it possible to send a signal to a specific thread to abort a read or a select? Thank you for any assistance you may be able to give. Rick Spangenberg infotech@discovernet.net ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: HOW-TO KILL THREADS 1997-10-27 5:00 HOW-TO KILL THREADS Richard Spangenberg @ 1997-10-28 5:00 ` Dave Butenhof 1997-10-28 5:00 ` Brian Silver 0 siblings, 1 reply; 5+ messages in thread From: Dave Butenhof @ 1997-10-28 5:00 UTC (permalink / raw) Richard Spangenberg wrote: > > We are trying to install a database (MYSQL) in a Dec/ALpha OSF1 3.2 machine. > Everything is up and running but we are concerned that there appears to be > do way to stop a thread if it starts to eat up CPU time. > > The problem is that pthread_kill doesn't exits. Is it possible to send a > signal to a specific thread to abort a read or a select? > > Thank you for any assistance you may be able to give. You really can't kill a "runaway" thread and hope to regain control. Remember that all the threads in the process run the same code, and access the same data. If one thread is doing something wrong, and you don't know why, you CANNOT assume that the other threads are "safe". Kill the process. DCE threads, the loose implementation of POSIX draft 4 threads that's part of DEC OSF/1 3.2, didn't have any way to send a signal to a particular thread. The concept was not supported either by the draft standard nor by the implementation. You can't even use cancellation, because DCE threads didn't have sufficient integration with the kernel to make kernel blocking functions into cancellation points. So the answer is, "no, you can't". And furthermore, even if you were on a Digital UNIX 4.0 system, which has POSIX threads, with pthread_kill and cancellable I/O functions, you shouldn't WANT to. Once something is wrong with the PROCESS, destroying a misbehaving thread is usually just removing a symptom of the real problem. /---------------------------[ 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 ]----------------/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: HOW-TO KILL THREADS 1997-10-28 5:00 ` Dave Butenhof @ 1997-10-28 5:00 ` Brian Silver 1997-10-29 5:00 ` Richard Spangenberg 0 siblings, 1 reply; 5+ messages in thread From: Brian Silver @ 1997-10-28 5:00 UTC (permalink / raw) Dave Butenhof wrote: > > Richard Spangenberg wrote: > > > > We are trying to install a database (MYSQL) in a Dec/ALpha OSF1 3.2 machine. > > Everything is up and running but we are concerned that there appears to be > > do way to stop a thread if it starts to eat up CPU time. [Snip] > So the answer is, "no, you can't". And furthermore, even if you were on > a Digital UNIX 4.0 system, which has POSIX threads, with pthread_kill > and cancellable I/O functions, you shouldn't WANT to. Once something is > wrong with the PROCESS, destroying a misbehaving thread is usually just > removing a symptom of the real problem. Just to add a little to this, it seems to me like the original poster wanted to kill a thread from outside of the process. (Like using the kill command). This isn't possible in 4.0 (and 3.2 for different reasons that Dave outlined previously) because there is no way for a generic process to get the necessary thread ids of threads in any other generic process. Furthermore, even if you had the necessary thread id, you'd still need a mechanism that said "signal this thread, but it lives in this process", and this just doesn't exist unless you write it into both processes. Even if you could cancel what you see as a "kernel" thread on 4.0 (and decendants) it won't do remotely what you expect it to do, and will (more than likely) cripple the process in some way that that will be unclear and non-predictable. Kernel threads don't map 1-1 to user threads like they did on 3.2 (and predecessors) as there is a 2-level scheduling implimentation in DECthreads. Bottom line: Nuke the process. You'll be happier in the end. Brian. -- Replace ! with @ for email address: silver!zko.dec.com ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: HOW-TO KILL THREADS 1997-10-28 5:00 ` Brian Silver @ 1997-10-29 5:00 ` Richard Spangenberg 1997-11-03 5:00 ` Dave Butenhof 0 siblings, 1 reply; 5+ messages in thread From: Richard Spangenberg @ 1997-10-29 5:00 UTC (permalink / raw) 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. 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. Rick Spangenberg infotech@discovernet.net ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: HOW-TO KILL THREADS 1997-10-29 5:00 ` Richard Spangenberg @ 1997-11-03 5:00 ` Dave Butenhof 0 siblings, 0 replies; 5+ messages in thread From: Dave Butenhof @ 1997-11-03 5:00 UTC (permalink / raw) 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 ]----------------/ ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1997-11-03 5:00 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 1997-10-27 5:00 HOW-TO KILL THREADS Richard Spangenberg 1997-10-28 5:00 ` Dave Butenhof 1997-10-28 5:00 ` Brian Silver 1997-10-29 5:00 ` Richard Spangenberg 1997-11-03 5: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