From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Fri, 29 Aug 2008 23:38:32 -0400 To: cinap_lenrek@gmx.de, 9fans@9fans.net Message-ID: In-Reply-To: <2b1f35826dd59f1276a806174536a4b5@gmx.de> References: <2b1f35826dd59f1276a806174536a4b5@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] notes and traps Topicbox-Message-UUID: 0b6394b6-ead4-11e9-9d60-3106f5b1d025 > No! Notes are bufferd in the up->note[] array. If you are in the note handler, > another process *can* send you further (NUser) notes without doing any harm. > > If we are in the note handler (up->notified == 1) and notify() gets hit, > it will do nothing and return 0 see: > > /sys/src/9/pc/trap.c: notify() > ... > if(n->flag!=NUser && (up->notified || up->notify==0)){ > if(n->flag == NDebug) > pprint("suicide: %s\n", n->msg); > qunlock(&up->debug); > pexit(n->msg, n->flag!=NDebug); > } > > if(up->notified){ > qunlock(&up->debug); > splhi(); > return 0; > } > ... > > The problem is when we get a NDebug note *after* an NUser note. Then i think you may be misunderstanding what i'm saying. the test for n->flag does not appear to be accidental. i am not quite sure why that test is there, but i go on the assumption that presotto knew what he was doing. if you're going to claim he was wrong, i think you'd better have good reasons. including explaining why it's okay to not terminate a process which has not handed a system note when it gets another. the example program is carefully constructed to abuse notes beyond reason. sleeping in a note handler seems like it's pushing the limits to me. having two threads sending notes to the same proc including one generating a constent stream of gpf's seems like it's a bit beyond what notes were intended for. if you remove the sleep from the note handler, all the notes are handled. i don't think by itself it's particularly compelling example. your vm example may be compelling. i don't understand it yet, though. so i can't say. i'm not arguing for broken system calls. but notes, like signals, tend to be convienent but fraught interfaces. maybe now that plan 9 has given in to multithreading, it's time to replace notes. - erik