diff options
Diffstat (limited to 'man/man3/ioproc.html')
-rw-r--r-- | man/man3/ioproc.html | 211 |
1 files changed, 0 insertions, 211 deletions
diff --git a/man/man3/ioproc.html b/man/man3/ioproc.html deleted file mode 100644 index 092bac91..00000000 --- a/man/man3/ioproc.html +++ /dev/null @@ -1,211 +0,0 @@ -<head> -<title>ioproc(3) - Plan 9 from User Space</title> -<meta content="text/html; charset=utf-8" http-equiv=Content-Type> -</head> -<body bgcolor=#ffffff> -<table border=0 cellpadding=0 cellspacing=0 width=100%> -<tr height=10><td> -<tr><td width=20><td> -<tr><td width=20><td><b>IOPROC(3)</b><td align=right><b>IOPROC(3)</b> -<tr><td width=20><td colspan=2> - <br> -<p><font size=+1><b>NAME </b></font><br> - -<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> - - closeioproc, iocall, ioclose, iointerrupt, iodial, ioopen, ioproc, - ioread, ioread9pmsg, ioreadn, iorecvfd, iosendfd, iosleep, iowrite - – slave I/O processes for threaded programs<br> - -</table> -<p><font size=+1><b>SYNOPSIS </b></font><br> - -<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> - - -<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> - - <tt><font size=+1>#include <u.h><br> - #include <libc.h><br> - #include <thread.h><br> - typedef struct Ioproc Ioproc;<br> - Ioproc* ioproc(void);<br> - int ioclose(Ioproc *io, int fd);<br> - int iodial(Ioproc *io, char *addr, char *local, char *dir, char - *cdfp);<br> - int ioopen(Ioproc *io, char *file, int omode);<br> - long ioread(Ioproc *io, int fd, void *a, long n);<br> - int ioread9pmsg(Ioproc *io, int fd, void *a, uint n);<br> - long ioreadn(Ioproc *io, int fd, void *a, long n);<br> - int iorecvfd(int socket);<br> - int iosendfd(int socket, int fd);<br> - int iosleep(int milli);<br> - long iowrite(Ioproc *io, int fd, void *a, long n);<br> - void iointerrupt(Ioproc *io);<br> - void closeioproc(Ioproc *io);<br> - long iocall(Ioproc *io, long (*op)(va_list *arg), ...);<br> - </font></tt> -</table> -<p><font size=+1><b>DESCRIPTION </b></font><br> - -<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> - - -<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> - - These routines provide access to I/O in slave procs. Since the - I/O itself is done in a slave proc, other threads in the calling - proc can run while the calling thread waits for the I/O to complete. - - <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> - - <i>Ioproc</i> forks a new slave proc and returns a pointer to the <tt><font size=+1>Ioproc</font></tt> - associated with it. <i>Ioproc</i> uses <i>mallocz</i> and <i>proccreate</i>; if either - fails, it calls <i>sysfatal</i> rather than return an error. - <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> - - <i>Ioclose</i>, <i>iodial</i>, <i>ioopen</i>, <i>ioread</i>, <i>ioread9pmsg</i>, <i>ioreadn</i>, <i>iorecvfd</i>, - <i>iosendfd</i>, <i>iosleep</i>, and <i>iowrite</i> execute the similarly named library - or system calls (see <a href="../man2/close.html"><i>close</i>(2)</a>, <a href="../man3/dial.html"><i>dial</i>(3)</a>, <a href="../man3/open.html"><i>open</i>(3)</a>, <a href="../man3/read.html"><i>read</i>(3)</a>, <a href="../man3/fcall.html"><i>fcall</i>(3)</a>, - <a href="../man3/sendfd.html"><i>sendfd</i>(3)</a>, and <a href="../man3/sleep.html"><i>sleep</i>(3)</a>) in the slave process associated with - <i>io</i>. It is an error to execute more than one call at a time in - an I/O - proc. - <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> - - <i>Iointerrupt</i> interrupts the call currently executing in the I/O - proc. If no call is executing, <i>iointerrupt</i> is a no-op. - <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> - - <i>Closeioproc</i> terminates the I/O proc and frees the associated <tt><font size=+1>Ioproc - . - <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> - </font></tt> - <i>Iocall</i> is a primitive that may be used to implement more slave - I/O routines. <i>Iocall</i> arranges for <i>op</i> to be called in <i>io</i>’s proc, - with <i>arg</i> set to the variable parameter list, returning the value - that <i>op</i> returns.<br> - -</table> -<p><font size=+1><b>EXAMPLE </b></font><br> - -<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> - - Relay messages between two file descriptors, counting the total - number of bytes seen:<br> - - <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> - - <tt><font size=+1>int tot;<br> - void<br> - relaythread(void *v)<br> - {<br> - - <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> - - int *fd, n;<br> - char buf[1024];<br> - Ioproc *io;<br> - fd = v;<br> - io = ioproc();<br> - while((n = ioread(io, fd[0], buf, sizeof buf)) > 0){<br> - if(iowrite(io, fd[1], buf, n) != n)<br> - sysfatal("iowrite: %r");<br> - tot += n;<br> - }<br> - closeioproc(io);<br> - - </table> - }<br> - void<br> - relay(int fd0, int fd1)<br> - {<br> - - <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> - - int fd[4];<br> - fd[0] = fd[3] = fd0;<br> - fd[1] = fd[2] = fd1;<br> - threadcreate(relaythread, fd, 8192);<br> - threadcreate(relaythread, fd+2, 8192);<br> - - </table> - }<br> - - <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> - </font></tt> - - </table> - If the two <i>relaythread</i> instances were running in different procs, - the common access to <i>tot</i> would be unsafe. - <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> - - Implement <i>ioread</i>:<br> - - <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> - - <tt><font size=+1>static long<br> - _ioread(va_list *arg)<br> - {<br> - - <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> - - int fd;<br> - void *a;<br> - long n;<br> - fd = va_arg(*arg, int);<br> - a = va_arg(*arg, void*);<br> - n = va_arg(*arg, long);<br> - return read(fd, a, n);<br> - - </table> - }<br> - long<br> - ioread(Ioproc *io, int fd, void *a, long n)<br> - {<br> - - <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> - - return iocall(io, _ioread, fd, a, n);<br> - - </table> - }<br> - </font></tt> - </table> - -</table> -<p><font size=+1><b>SOURCE </b></font><br> - -<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> - - <tt><font size=+1>/usr/local/plan9/src/libthread<br> - </font></tt> -</table> -<p><font size=+1><b>SEE ALSO </b></font><br> - -<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> - - <a href="../man3/dial.html"><i>dial</i>(3)</a>, <a href="../man3/open.html"><i>open</i>(3)</a>, <a href="../man3/read.html"><i>read</i>(3)</a>, <a href="../man3/thread.html"><i>thread</i>(3)</a><br> - -</table> -<p><font size=+1><b>BUGS </b></font><br> - -<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> - - <i>Iointerrupt</i> is currently unimplemented.<br> - -</table> - -<td width=20> -<tr height=20><td> -</table> -<!-- TRAILER --> -<table border=0 cellpadding=0 cellspacing=0 width=100%> -<tr height=15><td width=10><td><td width=10> -<tr><td><td> -<center> -<a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a> -</center> -</table> -<!-- TRAILER --> -</body></html> |