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 char *threadgetname(void);
19 int threadyield(void);
21 void _threadready(_Thread*);
22 void _threadswitch(void);
23 void _threadsetsysproc(void);
24 void _threadsleep(Rendez*);
25 _Thread *_threadwakeup(Rendez*);
26 #define yield threadyield
28 void _threadpin(void);
29 void _threadunpin(void);
32 * I am tired of making this mistake.
34 #define exits do_not_call_exits_in_threaded_programs
35 #define _exits do_not_call__exits_in_threaded_programs
42 void threadnotify(int(*f)(void*,char*), int);
47 void threaddaemonize(void);
51 * per proc and thread data
53 void **procdata(void);
54 void **threaddata(void);
57 * supplied by user instead of main.
58 * mainstacksize is size of stack allocated to run threadmain
60 void threadmain(int argc, char *argv[]);
61 extern int mainstacksize;
64 * channel communication
66 typedef struct Alt Alt;
67 typedef struct _Altarray _Altarray;
68 typedef struct Channel Channel;
106 /* [Edit .+1,./^$/ |cfn -h $PLAN9/src/libthread/channel.c] */
107 int chanalt(Alt *alts);
108 Channel* chancreate(int elemsize, int elemcnt);
109 void chanfree(Channel *c);
110 int chaninit(Channel *c, int elemsize, int elemcnt);
111 int channbrecv(Channel *c, void *v);
112 void* channbrecvp(Channel *c);
113 ulong channbrecvul(Channel *c);
114 int channbsend(Channel *c, void *v);
115 int channbsendp(Channel *c, void *v);
116 int channbsendul(Channel *c, ulong v);
117 int chanrecv(Channel *c, void *v);
118 void* chanrecvp(Channel *c);
119 ulong chanrecvul(Channel *c);
120 int chansend(Channel *c, void *v);
121 int chansendp(Channel *c, void *v);
122 int chansendul(Channel *c, ulong v);
123 void chansetname(Channel *c, char *fmt, ...);
126 #define nbrecv channbrecv
127 #define nbrecvp channbrecvp
128 #define nbrecvul channbrecvul
129 #define nbsend channbsend
130 #define nbsendp channbsendp
131 #define nbsendul channbsendul
132 #define recv chanrecv
133 #define recvp chanrecvp
134 #define recvul chanrecvul
135 #define send chansend
136 #define sendp chansendp
137 #define sendul chansendul
142 typedef struct Ref Ref;
153 * slave i/o processes
155 typedef struct Ioproc Ioproc;
157 /* [Edit .+1,/^$/ |cfn -h $PLAN9/src/libthread/io*.c] */
158 void closeioproc(Ioproc *io);
159 long iocall(Ioproc *io, long (*op)(va_list*), ...);
160 int ioclose(Ioproc *io, int fd);
161 int iodial(Ioproc *io, char *addr, char *local, char *dir, int *cdfp);
162 void iointerrupt(Ioproc *io);
163 int ioopen(Ioproc *io, char *path, int mode);
164 Ioproc* ioproc(void);
165 long ioread(Ioproc *io, int fd, void *a, long n);
166 int ioread9pmsg(Ioproc*, int, void*, int);
167 long ioreadn(Ioproc *io, int fd, void *a, long n);
168 int iorecvfd(Ioproc *, int);
169 int iosendfd(Ioproc*, int, int);
170 int iosleep(Ioproc *io, long n);
171 long iowrite(Ioproc *io, int fd, void *a, long n);
174 * exec external programs
176 void threadexec(Channel*, int[3], char*, char *[]);
177 void threadexecl(Channel*, int[3], char*, ...);
178 int threadspawn(int[3], char*, char*[]);
179 int threadspawnl(int[3], char*, ...);
180 Channel* threadwaitchan(void);
183 * alternate interface to threadwaitchan - don't use both!
185 Waitmsg* procwait(int pid);
187 #if defined(__cplusplus)
190 #endif /* _THREADH_ */