9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Sape Mullender <sape@plan9.bell-labs.com>
To: 9fans@9fans.net
Cc: 9fans@9fans.net
Subject: [9fans]  dial and time out
Date: Thu, 10 Sep 2009 11:57:02 +0200	[thread overview]
Message-ID: <c194c1043ecbf8810c546dbd2d616c75@plan9.bell-labs.com> (raw)
In-Reply-To: <e48ca67a55a6fbe6504fa8cfc08117e3@smgl.fr.eu.org>

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
>



  parent reply	other threads:[~2009-09-10  9:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-10  9:32 Mathieu L.
2009-09-10  9:34 ` erik quanstrom
2009-09-10  9:51   ` Mathieu L.
2009-09-10  9:59     ` erik quanstrom
2009-09-10 10:07     ` Sape Mullender
2009-09-10  9:57 ` Sape Mullender [this message]
2009-09-10 11:26   ` Mathieu L.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c194c1043ecbf8810c546dbd2d616c75@plan9.bell-labs.com \
    --to=sape@plan9.bell-labs.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).