16 iowrite \- slave I/O processes for threaded programs
29 typedef struct Ioproc Ioproc;
33 int ioclose(Ioproc *io, int fd);
34 int iodial(Ioproc *io, char *addr, char *local, char *dir, char *cdfp);
35 int ioopen(Ioproc *io, char *file, int omode);
36 long ioread(Ioproc *io, int fd, void *a, long n);
37 int ioread9pmsg(Ioproc *io, int fd, void *a, uint n);
38 long ioreadn(Ioproc *io, int fd, void *a, long n);
39 int iorecvfd(Ioproc *io, int socket);
40 int iosendfd(Ioproc *io, int socket, int fd);
41 int iosleep(Ioproc *io, long milli);
42 long iowrite(Ioproc *io, int fd, void *a, long n);
44 void iointerrupt(Ioproc *io);
45 void closeioproc(Ioproc *io);
47 long iocall(Ioproc *io, long (*op)(va_list *arg), ...);
51 These routines provide access to I/O in slave procs.
52 Since the I/O itself is done in a slave proc, other threads
53 in the calling proc can run while the calling thread
54 waits for the I/O to complete.
57 forks a new slave proc and returns a pointer to the
65 if either fails, it calls
67 rather than return an error.
81 similarly named library or system calls
91 in the slave process associated with
93 It is an error to execute more than one call
94 at a time in an I/O proc.
97 interrupts the call currently executing in the I/O proc.
98 If no call is executing,
103 terminates the I/O proc and frees the associated
107 is a primitive that may be used to implement
108 more slave I/O routines.
116 set to the variable parameter list,
117 returning the value that
121 Relay messages between two file descriptors,
122 counting the total number of bytes seen:
125 .ta +\w'xxxx'u +\w'xxxx'u +\w'xxxx'u
137 while((n = ioread(io, fd[0], buf, sizeof buf)) > 0){
138 if(iowrite(io, fd[1], buf, n) != n)
139 sysfatal("iowrite: %r");
146 relay(int fd0, int fd1)
152 threadcreate(relaythread, fd, 8192);
153 threadcreate(relaythread, fd+2, 8192);
159 instances are running in the same proc, so the
169 _ioread(va_list *arg)
175 fd = va_arg(*arg, int);
176 a = va_arg(*arg, void*);
177 n = va_arg(*arg, long);
178 return read(fd, a, n);
182 ioread(Ioproc *io, int fd, void *a, long n)
184 return iocall(io, _ioread, fd, a, n);
196 is currently unimplemented.
198 C99 disallows the use of pointers to
200 This interface will have to change to
201 use pointers to a structure containing a