From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <75b0c596a22523c46178f79e15a6a452@smgl.fr.eu.org> To: 9fans@9fans.net From: "Mathieu L." Date: Thu, 10 Sep 2009 13:26:47 +0200 In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-zlsxznggeuuoaijrgcmbmefewu" Subject: Re: [9fans] dial and time out Topicbox-Message-UUID: 6cc08312-ead5-11e9-9d60-3106f5b1d025 This is a multi-part message in MIME format. --upas-zlsxznggeuuoaijrgcmbmefewu Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Yes, I did mean thread, and I hadn't realized this would kill all the threads. I'll try with ioproc then, thanks for the example. Mathieu --upas-zlsxznggeuuoaijrgcmbmefewu Content-Type: message/rfc822 Content-Disposition: inline Return-Path: X-Original-To: lejatorn@smgl.fr.eu.org Delivered-To: lejatorn@smgl.fr.eu.org Received: by serenity.smgl.fr.eu.org (Postfix, from userid 58) id 083947E82E; Thu, 10 Sep 2009 12:12:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on serenity.smgl.fr.eu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.2.5 Received: from mail-bw0-f211.google.com (mail-bw0-f211.google.com [209.85.218.211]) by serenity.smgl.fr.eu.org (Postfix) with ESMTP id 2F5777E82A for ; Thu, 10 Sep 2009 12:11:59 +0200 (CEST) Received: by bwz7 with SMTP id 7so1607280bwz.11 for ; Thu, 10 Sep 2009 03:11:58 -0700 (PDT) Received: by 10.204.160.90 with SMTP id m26mr769900bkx.63.1252577518496; Thu, 10 Sep 2009 03:11:58 -0700 (PDT) X-Forwarded-To: lejatorn@smgl.fr.eu.org X-Forwarded-For: lejatorn@gmail.com lejatorn@smgl.fr.eu.org Delivered-To: lejatorn@gmail.com Received: by 10.204.101.133 with SMTP id c5cs15033bko; Thu, 10 Sep 2009 03:11:57 -0700 (PDT) Received: by 10.231.6.79 with SMTP id 15mr2557181iby.36.1252577516902; Thu, 10 Sep 2009 03:11:56 -0700 (PDT) Received: from gouda.swtch.com (gouda.swtch.com [67.207.142.3]) by mx.google.com with ESMTP id 11si1809757iwn.14.2009.09.10.03.11.56; Thu, 10 Sep 2009 03:11:56 -0700 (PDT) Received-SPF: pass (google.com: domain of 9fans-bounces+lejatorn=gmail.com@9fans.net designates 67.207.142.3 as permitted sender) client-ip=67.207.142.3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of 9fans-bounces+lejatorn=gmail.com@9fans.net designates 67.207.142.3 as permitted sender) smtp.mail=9fans-bounces+lejatorn=gmail.com@9fans.net Received: from localhost ([127.0.0.1] helo=gouda.swtch.com) by gouda.swtch.com with esmtp (Exim 4.69) (envelope-from <9fans-bounces@9fans.net>) id 1MlgVI-00030X-Ce; Thu, 10 Sep 2009 10:03:48 +0000 Received: from plan9.cs.bell-labs.com ([204.178.31.2]) by gouda.swtch.com with esmtp (Exim 4.69) (envelope-from ) id 1MlgVF-00030O-Vv for 9fans@9fans.net; Thu, 10 Sep 2009 10:03:46 +0000 Received: from plan9.cs.bell-labs.com ([172.31.204.79]) by plan9; Thu Sep 10 06:02:41 EDT 2009 Message-ID: To: 9fans@9fans.net Cc: 9fans@9fans.net Date: Thu, 10 Sep 2009 11:57:02 +0200 From: Sape Mullender In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: [9fans] dial and time out X-BeenThere: 9fans@9fans.net X-Mailman-Version: 2.1.10 Precedence: list Reply-To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> List-Id: Fans of the OS Plan 9 from Bell Labs <9fans.9fans.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: 9fans-bounces@9fans.net Errors-To: 9fans-bounces+lejatorn=gmail.com@9fans.net If you really mean thread and not proc, then what you suggest won't work. You can't kill a thread that's in the OS without killing the proc conyaining the thread (thereby killing all the other threads as well). You can have the proc catch notes and send a note to the proc which will interrupt any system call, thereby pulling the thread out of the dial. A more elgant way to do this would be to use ioproc(2), or to create procs explicitly to do the dial I/O. Sape > From: lejatorn@gmail.com > To: 9fans@9fans.net > Reply-To: 9fans@9fans.net > Date: Thu Sep 10 11:38:50 CES 2009 > Subject: [9fans] dial and time out > > Hello 9fans, > > I have a bunch of threads, simply scheduled with yield() at the moment > (I'll use alt later on), and each of them is calling dial() at some > point. I don't want the other threads to wait for "too long" when one > of them is blocked on a dial() that will eventually time out. > So I was thinking, for each of them, of creating a proc which would > be used as a timer; it would be created just before the call to dial, > wait for some time, and then kill the dial()ing thread. And as mechiel > suggested, the dial()ing thread would also be set to kill the timer > after it successfully dialed, hence not being killed if it was fast > enough. > > Is that the right way to go? If yes, can anyone think of an already > existing example I can look at? > > Mathieu > --upas-zlsxznggeuuoaijrgcmbmefewu--