9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] Quick question on stopping a process that waits for IO
Date: Tue,  4 Nov 2008 07:34:41 -0500	[thread overview]
Message-ID: <cd39dbb6fa8a5c9a365793c4c06bea2f@quanstro.net> (raw)
In-Reply-To: <1225759892.4781.179.camel@goose.sun.com>

>> Is there any way I can poke the target process so that it gets attention
>> from the scheduler an can be put in a Stopped state?
>
> I know, I know we all don't like those guys who talk to themselves
> on mailing lists replying to their own emails, but since there were
> no takers here's what I cooked up so far:
>    echo stop > /proc/n/ctl &
>    echo ping > /proc/n/note
>    cat /proc/n/note > /dev/null
>
> That of course doesn't quite work either since once I resume 'n'
> by issuing
>     echo start > /proc/n/ctl
> the process fails with:
>     error reading <stdin>: interrupted

this is an uncaught error in port/proc.c:/^sleep.  many interruptable
calls to sleep are wrapped by
	while(waserror())
		;
	sleep(...);
	poperror();

but this is a catch-22.  if the i/o resumed and didn't send a note,
it would not be possible to interrupt processes with del with rio's
current convention.

on the other hand, sending a note is the only way to get to procctl
unless one is doing syscall tracing.

oddly procctl says
/*
 *  called splhi() by notify().  See comment in notify for the
 *  reasoning.
 */
but there doesn't seem to be a comment in any version of notify
i can find.

>
> So the question remains -- what is the proper way of putting a process
> that waits for an IO into a Stopped state?

i don't think it's possible without changing the kernel.
but it's a good question, why does it work this way?
obviously one doesn't want to stop a process and kernel work in
the middle of i/o.  there may be locks involved, etc.
but one could easily check for Proc_stopme on syscall
exit.

does anyone remember the thinking that went into this?

- erik




  reply	other threads:[~2008-11-04 12:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-03  5:55 Roman Shaposhnik
2008-11-04  0:51 ` Roman V. Shaposhnik
2008-11-04 12:34   ` erik quanstrom [this message]
2008-11-07  5:51     ` Roman Shaposhnik
2008-11-04  1:01 ` ron minnich
2008-11-05  2:00   ` Roman V. Shaposhnik
2008-11-05  4:00     ` erik quanstrom
2008-11-05  4:47       ` Roman Shaposhnik
2008-11-05  4:01     ` erik quanstrom
2008-11-05  4:22       ` Roman Shaposhnik
2008-11-05 12:55         ` erik quanstrom
2008-11-07  5:48           ` Roman Shaposhnik
2008-11-06  5:40 ` Nathaniel W Filardo
2008-11-07  5:18   ` Roman Shaposhnik
2008-11-07  6:03     ` Nathaniel W Filardo
2008-11-07 11:57 erik quanstrom
2008-11-07 12:17 erik quanstrom
     [not found] <507c066f8ade431cfb2d23a36aa82837@quanstro.net>
2008-11-07 18:57 ` Roman V. Shaposhnik

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=cd39dbb6fa8a5c9a365793c4c06bea2f@quanstro.net \
    --to=quanstro@quanstro.net \
    --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).