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)
55 int (*fn)(void*, char*);
61 for(n=notes; n<enotes; n++){
64 if(onnotepid[i]!=p->pid || (fn = onnote[i])==nil)
70 _threaddebug(DBGNOTE, "Unhandled note %s, proc %p\n", n->s, p);
73 else if(strncmp(n->s, "sys:", 4)==0)
84 _threadnote(void *v, char *s)
89 _threaddebug(DBGNOTE, "Got note %s", s);
90 if(strncmp(s, "sys:", 4) == 0)
93 if(_threadexitsallstatus){
94 _threaddebug(DBGNOTE, "Threadexitsallstatus = '%s'\n", _threadexitsallstatus);
95 _exits(_threadexitsallstatus);
98 if(strcmp(s, "threadint")==0)
101 p = _threadgetproc();
105 for(n=notes; n<enotes; n++)
106 if(canlock(&n->inuse))
109 sysfatal("libthread: too many delayed notes");
110 utfecpy(n->s, n->s+ERRMAX, s);
124 p = _threadgetproc();
135 p = _threadgetproc();
140 delayednotes(p, nil);