9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] another kernel implementation question
@ 2011-01-27 10:54 Steve Simon
  2011-01-27 11:35 ` Anthony Martin
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Simon @ 2011-01-27 10:54 UTC (permalink / raw)
  To: 9fans

I don't get gow notes work WRT up->nerrlab.

say we schedule an alarm() call, and then go to sleep.

the note will fire when the alarm expires and cause
the processes notify function to be called.

this notify function calls noted() and in doing so sets
up->nerrlab to zero. assuming noted was called with NCONT
the alarm function will be made ready and will return, doing
poperror as it goes.

I would expect this to give an error of the form:

	bad errstack [%lud]: %d extra

clearly this doesn't happen so there is some magic I don't
understand going on here, but what is it?

Thanks all.

-Steve



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] another kernel implementation question
  2011-01-27 10:54 [9fans] another kernel implementation question Steve Simon
@ 2011-01-27 11:35 ` Anthony Martin
  2011-01-27 13:29   ` Steve Simon
  0 siblings, 1 reply; 4+ messages in thread
From: Anthony Martin @ 2011-01-27 11:35 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Waserror increments up->nerrlab before setting up
the next label on the error stack which means the
poperror in question returns it to zero.

  Anthony



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] another kernel implementation question
  2011-01-27 11:35 ` Anthony Martin
@ 2011-01-27 13:29   ` Steve Simon
  2011-01-27 14:48     ` Anthony Martin
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Simon @ 2011-01-27 13:29 UTC (permalink / raw)
  To: 9fans

> Waserror increments up->nerrlab before setting up
> the next label on the error stack which means the
> poperror in question returns it to zero.

Yep, I get this part, and for nearly all syscalls its straightforward,
fork() is different (I was stumpped by that a few months ago), and it seems
notes are different too.

The difference comes from the fact that sleep is deep inside its
stack/errlab hierarchy when it receives a note. This causes it
to jump to the notify function (still in the users context),
the notify function then calls back into the kernel (noted()).

this is where it gets weird, as on entry to the kernel syscall() zeros
up->nerrlab and so throws away the processes error history. Then if noted()
wants to continue the user process I would expect sleep to get resumed
and to recurr out of its stack and hit several poperror()s and end up with
a negative nerrlab!

so how does it work in the ntoe case?

-Steve



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] another kernel implementation question
  2011-01-27 13:29   ` Steve Simon
@ 2011-01-27 14:48     ` Anthony Martin
  0 siblings, 0 replies; 4+ messages in thread
From: Anthony Martin @ 2011-01-27 14:48 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Steve Simon <steve@quintile.net> once said:
> The difference comes from the fact that sleep is deep inside its
> stack/errlab hierarchy when it receives a note. This causes it
> to jump to the notify function (still in the users context),
> the notify function then calls back into the kernel (noted()).
>
> this is where it gets weird, as on entry to the kernel syscall() zeros
> up->nerrlab and so throws away the processes error history. Then if noted()
> wants to continue the user process I would expect sleep to get resumed
> and to recurr out of its stack and hit several poperror()s and end up with
> a negative nerrlab!
>
> so how does it work in the ntoe case?

I think it goes something like this.

syssleep
  --> tsleep
    --> sleep
	    when awakened, checks notepending and calls
		error with Eintr ("interrupted"), then jumps
		back to the error-branch of waserror in syscall
		--> syscall
		    sets errstr, calls notify, etc.

alarmkproc
  --> postnote
      sets notepending and wakes the sleeping proc

I'm quite tired, so I may have missed a step.

  Anthony



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-27 14:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-27 10:54 [9fans] another kernel implementation question Steve Simon
2011-01-27 11:35 ` Anthony Martin
2011-01-27 13:29   ` Steve Simon
2011-01-27 14:48     ` Anthony Martin

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