12 iowrite \- slave I/O processes for threaded programs
25 typedef struct Ioproc Ioproc;
29 int ioopen(Ioproc *io, char *file, int omode);
30 int ioclose(Ioproc *io, int fd);
31 long ioread(Ioproc *io, int fd, void *a, long n);
32 long ioreadn(Ioproc *io, int fd, void *a, long n);
33 long iowrite(Ioproc *io, int fd, void *a, long n);
34 int iodial(Ioproc *io, char *addr, char *local, char *dir, char *cdfp);
36 void iointerrupt(Ioproc *io);
37 void closeioproc(Ioproc *io);
39 long iocall(Ioproc *io, long (*op)(va_list *arg), ...);
43 These routines provide access to I/O in slave procs.
44 Since the I/O itself is done in a slave proc, other threads
45 in the calling proc can run while the calling thread
46 waits for the I/O to complete.
49 forks a new slave proc and returns a pointer to the
57 if either fails, it calls
59 rather than return an error.
69 similarly named library or system calls
75 in the slave process associated with
77 It is an error to execute more than one call
78 at a time in an I/O proc.
81 interrupts the call currently executing in the I/O proc.
82 If no call is executing,
87 terminates the I/O proc and frees the associated
91 is a primitive that may be used to implement
92 more slave I/O routines.
100 set to the variable parameter list,
101 returning the value that
105 Relay messages between two file descriptors,
106 counting the total number of bytes seen:
109 .ta +\w'xxxx'u +\w'xxxx'u +\w'xxxx'u
121 while((n = ioread(io, fd[0], buf, sizeof buf)) > 0){
122 if(iowrite(io, fd[1], buf, n) != n)
123 sysfatal("iowrite: %r");
130 relay(int fd0, int fd1)
136 threadcreate(relaythread, fd, 8192);
137 threadcreate(relaythread, fd+2, 8192);
143 instances were running in different procs, the
154 _ioread(va_list *arg)
160 fd = va_arg(*arg, int);
161 a = va_arg(*arg, void*);
162 n = va_arg(*arg, long);
163 return read(fd, a, n);
167 ioread(Ioproc *io, int fd, void *a, long n)
169 return iocall(io, _ioread, fd, a, n);
173 .B /sys/src/libthread/io*.c