14 iowrite \- slave I/O processes for threaded programs
27 typedef struct Ioproc Ioproc;
31 int ioopen(Ioproc *io, char *file, int omode);
32 int ioclose(Ioproc *io, int fd);
33 long ioread(Ioproc *io, int fd, void *a, long n);
34 long ioreadn(Ioproc *io, int fd, void *a, long n);
35 long iowrite(Ioproc *io, int fd, void *a, long n);
36 int iodial(Ioproc *io, char *addr, char *local, char *dir, char *cdfp);
37 int iosleep(Ioproc *io, long n);
39 int ioflush(Ioproc *io);
40 void iointerrupt(Ioproc *io);
41 void closeioproc(Ioproc *io);
43 long iocall(Ioproc *io, long (*op)(va_list *arg), ...);
47 These routines provide access to I/O in slave procs.
48 Since the I/O itself is done in a slave proc, other threads
49 in the calling proc can run while the calling thread
50 waits for the I/O to complete.
53 forks a new slave proc and returns a pointer to the
61 if either fails, it calls
63 rather than return an error.
74 similarly named library or system calls
80 in the slave process associated with
84 interrupts the next or currently executing call in the I/O proc. If
85 there was no call executing, the interrupt will stay pending and the
86 next I/O call will get interrupted.
89 executes a non-op in the I/O proc. It is commonly called after
91 to clear a pending interrupt.
94 terminates the I/O proc and frees the associated
98 is a primitive that may be used to implement
99 more slave I/O routines.
107 set to the variable parameter list,
108 returning the value that
112 Relay messages between two file descriptors,
113 counting the total number of bytes seen:
116 .ta +\w'xxxx'u +\w'xxxx'u +\w'xxxx'u
128 while((n = ioread(io, fd[0], buf, sizeof buf)) > 0){
129 if(iowrite(io, fd[1], buf, n) != n)
130 sysfatal("iowrite: %r");
137 relay(int fd0, int fd1)
143 threadcreate(relaythread, fd, 8192);
144 threadcreate(relaythread, fd+2, 8192);
150 instances were running in different procs, the
160 _ioread(va_list *arg)
166 fd = va_arg(*arg, int);
167 a = va_arg(*arg, void*);
168 n = va_arg(*arg, long);
169 return read(fd, a, n);
173 ioread(Ioproc *io, int fd, void *a, long n)
175 return iocall(io, _ioread, fd, a, n);
179 .B /sys/src/libthread/io*.c