4 #include "threadimpl.h"
10 typedef struct Note Note;
14 Proc *proc; /* recipient */
15 char s[ERRMAX]; /* arg2 */
18 static Note notes[128];
19 static Note *enotes = notes+nelem(notes);
20 static int (*onnote[NFN])(void*, char*);
21 static int onnotepid[NFN];
22 static Lock onnotelock;
25 threadnotify(int (*f)(void*, char*), int in)
28 int (*from)(void*, char*), (*to)(void*, char*);
33 topid = _threadgetproc()->pid;
51 delayednotes(Proc *p, void *v)
56 int (*fn)(void*, char*);
62 for(n=notes; n<enotes; n++){
69 if(onnotepid[i]!=p->pid || (fn = onnote[i])==nil)
75 _threaddebug(DBGNOTE, "Unhandled note %s, proc %p\n", n->s, p);
78 else if(strncmp(n->s, "sys:", 4)==0)
87 _threadnote(void *v, char *s)
92 _threaddebug(DBGNOTE, "Got note %s", s);
93 if(strncmp(s, "sys:", 4) == 0)
96 if(_threadexitsallstatus){
97 _threaddebug(DBGNOTE, "Threadexitsallstatus = '%s'\n", _threadexitsallstatus);
98 _exits(_threadexitsallstatus);
101 if(strcmp(s, "threadint")==0)
104 p = _threadgetproc();
108 for(n=notes; n<enotes; n++)
109 if(canlock(&n->inuse))
112 sysfatal("libthread: too many delayed notes");
113 utfecpy(n->s, n->s+ERRMAX, s);
127 p = _threadgetproc();
138 p = _threadgetproc();
143 delayednotes(p, nil);