Description:
第六個作業為 8.10, page 299.
也就是作 asynchrous read, and asynchrouns write. 主要程式就
作 `讀 stdin, 寫 stdout' 的動作, 直到 EOF 為止.
執行的過程可能為:
$ ./a.out infile outfile <----- copy infile to outfile
hello i'm klim with async read and async write
hello i'm klim <---- read stdin and echo it to stdout ...
...
...
[Copy completed] <------ when the copy is completed, show something
.. to screen
..
^D
$
為了模擬 slow device, 我改寫了課本的 periodicasterisk.c, 使之能每秒作
n (argv[1]) 次讀寫的動作, 每次皆從 stdin 讀一個字完, 再將之寫到 stdout.
( 程式 )
透過 FIFO, 此程式可與這次作業互動如下:
1st shell:
$ periodicchars 12 < FIFO
....... <---- the contents of infile is shown here
in the rate of 12 chars per second
2nd shell:
$ ./a.out infile FIFO <----- the contents of infile is sent to FIFO
hello klim
hello klim
.......
deadline: 5/07, 00:05 am