9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: cinap_lenrek@gmx.de
To: 9fans@9fans.net
Subject: Re: [9fans] notes and traps
Date: Sat, 30 Aug 2008 20:09:49 +0200	[thread overview]
Message-ID: <994ac677ae295f63e42e22b7cbbe5a70@gmx.de> (raw)
In-Reply-To: <003239afe18d1b7672c1f71363ec9e64@coraid.com>

> i'm not convinced that you've explained why this change is
> correct or why it could solve the problem. after all, the
> NNOTED array is only 5 entries long.  what if one gets 5
> user notes before the system note?
> do you kill the process (isn't this how it works now?),
> make notes unreliable or block the sender? none of these
> options seems like an improvement to me.

Hm, i think here would be a better way to handle it without
losing user notes while make sure internal system notes
get posted (and handled) in any case.

What if we change postnote to:

int
postnote(Proc *p, int dolock, char *n, int flag)
{
	int x, s, ret;
	Rendez *r;
	Proc *d, **l;

	if(dolock)
		qlock(&p->debug);

	if(flag != NUser){
		x = 0;
		if(p->nnote < NNOTE){
			if(p->nnote)
				memmove(&p->note[0], &p->note[1], p->nnote * sizeof(p->note[0]));
			p->nnote++;
		}
	} else {
		x = -1;
		if(p->nnote+1 < NNOTE)
			x = p->nnote++;
	}

	ret = 0;
	if(x >= 0) {
		strcpy(p->note[x].msg, n);
		p->note[x].flag = flag;
		ret = 1;
	}
	p->notepending = 1;
	if(dolock)
		qunlock(&p->debug);
...

In that case, if a external note is posted, we make sure here is
always room for one further internal note in the array. (see the
p->nnote+1 < NNOTE)

On arrival of a internal note, we move the rest down the array
and put our note in the first entry.

So the following conditions hold true:

- internal notes get *always* posted (so the process gets terminated
  if its not handled or while in the note handler)
- we do not drop external notes on internal note arrival and the sender
  can detect if posting the note failed.
- internal notes get not queued after external notes so they will be
  handled by the next call to notify() and not tick notify() to think
  that while processing a previous user note, that this caused an
  internal note and kill the process before it has a chance to see the
  that note.

Anything wrong here?

--
cinap




      parent reply	other threads:[~2008-08-30 18:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-28 13:21 Kernel Panic
2008-08-28 14:09 ` erik quanstrom
2008-08-28 15:28   ` Kernel Panic
2008-08-29 10:04   ` Kernel Panic
2008-08-29 10:09     ` Kernel Panic
2008-08-29 18:26     ` erik quanstrom
2008-08-30  2:18       ` cinap_lenrek
2008-08-30  3:38         ` erik quanstrom
2008-08-30  5:48           ` cinap_lenrek
2008-08-30 10:50             ` Steve Simon
2008-08-30 14:04             ` erik quanstrom
2008-08-30 17:40               ` cinap_lenrek
2008-08-30 18:09               ` cinap_lenrek [this message]

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=994ac677ae295f63e42e22b7cbbe5a70@gmx.de \
    --to=cinap_lenrek@gmx.de \
    --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).