3 #if defined(__cplusplus)
10 * basic procs and threads
12 int proccreate(void (*f)(void *arg), void *arg, unsigned int stacksize);
13 int threadcreate(void (*f)(void *arg), void *arg, unsigned int stacksize);
14 void threadexits(char *);
15 void threadexitsall(char *);
16 void threadsetname(char*, ...);
17 void threadsetstate(char*, ...);
18 void threadneedbackground(void);
19 char *threadgetname(void);
20 int threadyield(void);
22 void _threadready(_Thread*);
23 void _threadswitch(void);
24 void _threadsetsysproc(void);
25 void _threadsleep(Rendez*);
26 _Thread *_threadwakeup(Rendez*);
27 #define yield threadyield
29 void _threadpin(void);
30 void _threadunpin(void);
33 * I am tired of making this mistake.
35 #define exits do_not_call_exits_in_threaded_programs
36 #define _exits do_not_call__exits_in_threaded_programs
43 void threadnotify(int(*f)(void*,char*), int);
48 void threaddaemonize(void);
52 * per proc and thread data
54 void **procdata(void);
55 void **threaddata(void);
58 * supplied by user instead of main.
59 * mainstacksize is size of stack allocated to run threadmain
61 void threadmain(int argc, char *argv[]);
62 extern int mainstacksize;
64 int threadmaybackground(void);
67 * channel communication
69 typedef struct Alt Alt;
70 typedef struct _Altarray _Altarray;
71 typedef struct Channel Channel;
109 /* [Edit .+1,./^$/ |cfn -h $PLAN9/src/libthread/channel.c] */
110 int chanalt(Alt *alts);
111 Channel* chancreate(int elemsize, int elemcnt);
112 void chanfree(Channel *c);
113 int channbrecv(Channel *c, void *v);
114 void* channbrecvp(Channel *c);
115 ulong channbrecvul(Channel *c);
116 int channbsend(Channel *c, void *v);
117 int channbsendp(Channel *c, void *v);
118 int channbsendul(Channel *c, ulong v);
119 int chanrecv(Channel *c, void *v);
120 void* chanrecvp(Channel *c);
121 ulong chanrecvul(Channel *c);
122 int chansend(Channel *c, void *v);
123 int chansendp(Channel *c, void *v);
124 int chansendul(Channel *c, ulong v);
125 void chansetname(Channel *c, char *fmt, ...);
128 #define nbrecv channbrecv
129 #define nbrecvp channbrecvp
130 #define nbrecvul channbrecvul
131 #define nbsend channbsend
132 #define nbsendp channbsendp
133 #define nbsendul channbsendul
134 #define recv chanrecv
135 #define recvp chanrecvp
136 #define recvul chanrecvul
137 #define send chansend
138 #define sendp chansendp
139 #define sendul chansendul
144 typedef struct Ref Ref;
155 * slave i/o processes
157 typedef struct Ioproc Ioproc;
159 /* [Edit .+1,/^$/ |cfn -h $PLAN9/src/libthread/io*.c] */
160 void closeioproc(Ioproc *io);
161 long iocall(Ioproc *io, long (*op)(va_list*), ...);
162 int ioclose(Ioproc *io, int fd);
163 int iodial(Ioproc *io, char *addr, char *local, char *dir, int *cdfp);
164 void iointerrupt(Ioproc *io);
165 int ioopen(Ioproc *io, char *path, int mode);
166 Ioproc* ioproc(void);
167 long ioread(Ioproc *io, int fd, void *a, long n);
168 int ioread9pmsg(Ioproc*, int, void*, int);
169 long ioreadn(Ioproc *io, int fd, void *a, long n);
170 int iorecvfd(Ioproc *, int);
171 int iosendfd(Ioproc*, int, int);
172 int iosleep(Ioproc *io, long n);
173 long iowrite(Ioproc *io, int fd, void *a, long n);
176 * exec external programs
178 void threadexec(Channel*, int[3], char*, char *[]);
179 void threadexecl(Channel*, int[3], char*, ...);
180 int threadspawn(int[3], char*, char*[]);
181 int threadspawnd(int[3], char*, char*[], char*);
182 int threadspawnl(int[3], char*, ...);
183 Channel* threadwaitchan(void);
186 * alternate interface to threadwaitchan - don't use both!
188 Waitmsg* procwait(int pid);
190 #if defined(__cplusplus)
193 #endif /* _THREADH_ */