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);
20 void _threadready(_Thread*);
21 void _threadswitch(void);
22 void _threadsetsysproc(void);
23 void _threadsleep(Rendez*);
24 _Thread *_threadwakeup(Rendez*);
25 #define yield threadyield
28 * I am tired of making this mistake.
30 #define exits do_not_call_exits_in_threaded_programs
31 #define _exits do_not_call__exits_in_threaded_programs
38 void threadnotify(int(*f)(void*,char*), int);
43 void threaddaemonize(void);
47 * per proc and thread data
49 void **procdata(void);
50 void **threaddata(void);
53 * supplied by user instead of main.
54 * mainstacksize is size of stack allocated to run threadmain
56 void threadmain(int argc, char *argv[]);
57 extern int mainstacksize;
60 * channel communication
62 typedef struct Alt Alt;
63 typedef struct _Altarray _Altarray;
64 typedef struct Channel Channel;
103 /* [Edit .+1,./^$/ |cfn -h $PLAN9/src/libthread/channel.c] */
104 int chanalt(Alt *alts);
105 Channel* chancreate(int elemsize, int elemcnt);
106 void chanfree(Channel *c);
107 int chaninit(Channel *c, int elemsize, int elemcnt);
108 int channbrecv(Channel *c, void *v);
109 void* channbrecvp(Channel *c);
110 ulong channbrecvul(Channel *c);
111 int channbsend(Channel *c, void *v);
112 int channbsendp(Channel *c, void *v);
113 int channbsendul(Channel *c, ulong v);
114 int chanrecv(Channel *c, void *v);
115 void* chanrecvp(Channel *c);
116 ulong chanrecvul(Channel *c);
117 int chansend(Channel *c, void *v);
118 int chansendp(Channel *c, void *v);
119 int chansendul(Channel *c, ulong v);
120 void chansetname(Channel *c, char *fmt, ...);
123 #define nbrecv channbrecv
124 #define nbrecvp channbrecvp
125 #define nbrecvul channbrecvul
126 #define nbsend channbsend
127 #define nbsendp channbsendp
128 #define nbsendul channbsendul
129 #define recv chanrecv
130 #define recvp chanrecvp
131 #define recvul chanrecvul
132 #define send chansend
133 #define sendp chansendp
134 #define sendul chansendul
139 typedef struct Ref Ref;
150 * slave i/o processes
152 typedef struct Ioproc Ioproc;
154 /* [Edit .+1,/^$/ |cfn -h $PLAN9/src/libthread/io*.c] */
155 void closeioproc(Ioproc *io);
156 long iocall(Ioproc *io, long (*op)(va_list*), ...);
157 int ioclose(Ioproc *io, int fd);
158 int iodial(Ioproc *io, char *addr, char *local, char *dir, int *cdfp);
159 void iointerrupt(Ioproc *io);
160 int ioopen(Ioproc *io, char *path, int mode);
161 Ioproc* ioproc(void);
162 long ioread(Ioproc *io, int fd, void *a, long n);
163 int ioread9pmsg(Ioproc*, int, void*, int);
164 long ioreadn(Ioproc *io, int fd, void *a, long n);
165 int iorecvfd(Ioproc *, int);
166 int iosendfd(Ioproc*, int, int);
167 int iosleep(Ioproc *io, long n);
168 long iowrite(Ioproc *io, int fd, void *a, long n);
171 * exec external programs
173 void threadexec(Channel*, int[3], char*, char *[]);
174 void threadexecl(Channel*, int[3], char*, ...);
175 int threadspawn(int[3], char*, char*[]);
176 int threadspawnl(int[3], char*, ...);
177 Channel* threadwaitchan(void);
179 #if defined(__cplusplus)
182 #endif /* _THREADH_ */