6 #include "/sys/src/libthread/threadimpl.h"
12 typedef struct Note Note;
16 Proc *proc; /* recipient */
17 char s[ERRMAX]; /* arg2 */
20 static Note notes[128];
21 static Note *enotes = notes+nelem(notes);
22 static int (*onnote[NFN])(void*, char*);
23 static int onnotepid[NFN];
24 static Lock onnotelock;
27 threadnotify(int (*f)(void*, char*), int in)
30 int (*from)(void*, char*), (*to)(void*, char*);
35 topid = _threadgetproc()->pid;
53 delayednotes(Proc *p, void *v)
57 int (*fn)(void*, char*);
63 for(n=notes; n<enotes; n++){
66 if(onnotepid[i]!=p->pid || (fn = onnote[i])==nil)
72 _threaddebug(DBGNOTE, "Unhandled note %s, proc %p\n", n->s, p);
75 else if(strncmp(n->s, "sys:", 4)==0)
86 _threadnote(void *v, char *s)
91 _threaddebug(DBGNOTE, "Got note %s", s);
92 // if(strncmp(s, "sys:", 4) == 0)
95 // if(_threadexitsallstatus){
96 // _threaddebug(DBGNOTE, "Threadexitsallstatus = '%s'\n", _threadexitsallstatus);
97 // _exits(_threadexitsallstatus);
100 if(strcmp(s, "threadint")==0)
103 p = _threadgetproc();
107 for(n=notes; n<enotes; n++)
108 if(canlock(&n->inuse))
111 sysfatal("libthread: too many delayed notes");
112 utfecpy(n->s, n->s+ERRMAX, s);
126 p = _threadgetproc();
137 p = _threadgetproc();
142 delayednotes(p, nil);