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);
52 * supplied by user instead of main.
53 * mainstacksize is size of stack allocated to run threadmain
55 void threadmain(int argc, char *argv[]);
56 extern int mainstacksize;
59 * channel communication
61 typedef struct Alt Alt;
62 typedef struct _Altarray _Altarray;
63 typedef struct Channel Channel;
102 /* [Edit .+1,./^$/ |cfn -h $PLAN9/src/libthread/channel.c] */
103 int chanalt(Alt *alts);
104 Channel* chancreate(int elemsize, int elemcnt);
105 void chanfree(Channel *c);
106 int chaninit(Channel *c, int elemsize, int elemcnt);
107 int channbrecv(Channel *c, void *v);
108 void* channbrecvp(Channel *c);
109 ulong channbrecvul(Channel *c);
110 int channbsend(Channel *c, void *v);
111 int channbsendp(Channel *c, void *v);
112 int channbsendul(Channel *c, ulong v);
113 int chanrecv(Channel *c, void *v);
114 void* chanrecvp(Channel *c);
115 ulong chanrecvul(Channel *c);
116 int chansend(Channel *c, void *v);
117 int chansendp(Channel *c, void *v);
118 int chansendul(Channel *c, ulong v);
119 void chansetname(Channel *c, char *fmt, ...);
122 #define nbrecv channbrecv
123 #define nbrecvp channbrecvp
124 #define nbrecvul channbrecvul
125 #define nbsend channbsend
126 #define nbsendp channbsendp
127 #define nbsendul channbsendul
128 #define recv chanrecv
129 #define recvp chanrecvp
130 #define recvul chanrecvul
131 #define send chansend
132 #define sendp chansendp
133 #define sendul chansendul
138 typedef struct Ref Ref;
149 * slave i/o processes
151 typedef struct Ioproc Ioproc;
153 /* [Edit .+1,/^$/ |cfn -h $PLAN9/src/libthread/io*.c] */
154 void closeioproc(Ioproc *io);
155 long iocall(Ioproc *io, long (*op)(va_list*), ...);
156 int ioclose(Ioproc *io, int fd);
157 int iodial(Ioproc *io, char *addr, char *local, char *dir, int *cdfp);
158 void iointerrupt(Ioproc *io);
159 int ioopen(Ioproc *io, char *path, int mode);
160 Ioproc* ioproc(void);
161 long ioread(Ioproc *io, int fd, void *a, long n);
162 int ioread9pmsg(Ioproc*, int, void*, int);
163 long ioreadn(Ioproc *io, int fd, void *a, long n);
164 int iorecvfd(Ioproc *, int);
165 int iosendfd(Ioproc*, int, int);
166 int iosleep(Ioproc *io, long n);
167 long iowrite(Ioproc *io, int fd, void *a, long n);
170 * exec external programs
172 void threadexec(Channel*, int[3], char*, char *[]);
173 void threadexecl(Channel*, int[3], char*, ...);
174 int threadspawn(int[3], char*, char*[]);
175 int threadspawnl(int[3], char*, ...);
176 Channel* threadwaitchan(void);
178 #if defined(__cplusplus)
181 #endif /* _THREADH_ */