9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Quick question on stopping a process that waits for IO
@ 2008-11-03  5:55 Roman Shaposhnik
  2008-11-04  0:51 ` Roman V. Shaposhnik
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Roman Shaposhnik @ 2008-11-03  5:55 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Guys,

when somebody tries to stop a process that is waiting for the IO the
process
doesn't get transferred to a Stopped state immediately but only when
the scheduler sees it for the first time. This leads to a process
writing to
a /proc/n/ctl being put in a Stopwait state which is a bit inconvenient.

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?

Thanks,
Roman.



^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: [9fans] Quick question on stopping a process that waits for IO
@ 2008-11-07 11:57 erik quanstrom
  0 siblings, 0 replies; 18+ messages in thread
From: erik quanstrom @ 2008-11-07 11:57 UTC (permalink / raw)
  To: nwf, 9fans

> >> Did I miss something obvious?
> >
> > And this would be a million dollar question here. I don't
> > think you did (although Eric (sic) constantly warns us of
> > dragons), but on the other hand I have very little
> > experience with the kernel itself.
>
> I hope somebody comments on the fencing that is or isn't needed here.  Since
> we have parts of the kernel peeking witout locks at ->procctl, I worry about
> races, and wonder how, or if, the current design avoids them.

memory fencing only forces the instruction
stream to be read, write or r/w coherent with
the local processor.  it is of no help at all for
concurrent access.  supposing there is a problem,
memory fencing will not help.  you would need
an ilock.  i didn't spend enough time looking
at pc/trap.c to convince myself one way or the
other, but the main access (other than syscall
tracing) seemed to be a read of the variable
to transition to stopped state.  this race is
likely benign.  you'll just go around again and
catch it later.

notes are hard.  and the problem they're intended
to solve is how to interrupt a single-threaded process.
if you're writing something new and you think you
might want to extend notes, i think you would be
much happier using the thread library and living
in user space.

> in local store -- that drove the design of the Coyotos kernel to being a
> strictly transactional system.  AFAIR there it is always possible to tell a

it's easy to have a design where you let the dragons
play and you need to bring out some serious weaponry
to deal with your problems.  (and it is possible to get
carried away looking for concurrency problems.)
a good design like plan 9 keeps the dragons locked up,
mostly.

- erik



^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: [9fans] Quick question on stopping a process that waits for IO
@ 2008-11-07 12:17 erik quanstrom
  0 siblings, 0 replies; 18+ messages in thread
From: erik quanstrom @ 2008-11-07 12:17 UTC (permalink / raw)
  To: rvs, 9fans

> >> The target process is *already* waiting for the IO stuck inside the
> >> kernel. It is not on a runqueue, not it is considered to be places
> >> there.
> >
> > since procwrite doesn't acquire anything other than the debug lock,
> > how do you know?  the proc could start up again before you notice.
>
> How? If there's a stop message already written to /proc/n/ctl. Once
> that is done, the process is guaranteed to be in 2 states and those
> states only: continue waiting for the I/O, being actually Stopped.
> Both of the don't let the scheduler take it to the runqueue.

here's the senerio, i think  (works fine on a single processor)
a			b
acquire debug lock
sleep			complete io
			sched
			run a bit
			syscall
wakeup

- erik



^ permalink raw reply	[flat|nested] 18+ messages in thread
[parent not found: <507c066f8ade431cfb2d23a36aa82837@quanstro.net>]

end of thread, other threads:[~2008-11-07 18:57 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-03  5:55 [9fans] Quick question on stopping a process that waits for IO Roman Shaposhnik
2008-11-04  0:51 ` Roman V. Shaposhnik
2008-11-04 12:34   ` erik quanstrom
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

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).