testio.sh
(see other side) arranges via mtip to input 0123456789012345678901… at a slow
rate, to testio.lnx, while running testio.lnx
The little box shows where “hi!” is output in the original supplied hw1. The output shows before the kprintf of “write of 4 returned 4” because the supplied ttywrite code has used polling output to output the chars one by one.
Key:
italics: kprintf output, or other polling output
Plain text: output from interrupt-driven write
Underlined
text: echoes from input to interrupt-driven reads
Bold text: echoes from input to polling reads
testio.sh <system number> OS-handled read, so interrupt-driven
… reboot output
Tutor> ~downloading testio.lnx “Tutor”, etc. is output using polling
.........Done. but
“downloading…” is mtip/OS output
Download done, setting EIP to 100100.
Tutor> GO 100100
Running with console device
TTY1 kprintf output from testio
ioinit();
Trying simple
write...
write(ldev,"hi!\n",4);
write of 4 returned 4 (write returns with all 4 chars still in queue)
<doing delay>
hi! (output during delay loop)
Trying longer write write(ldev, "abcdefghi", 9)
abcwrite of 9 returned 9 (abc out, write returns with full queue, 6 chars)
<doing delay>
defghi (last queue-full output during delay loop)
Trying write of 80-char string... got = write(ldev, buf, BUFLEN);
AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ[[\\]]^^__``aabbccddee
write returned 80
<doing delay>
ffgghh012 (finish output during delay loop, 012 input/echoed)
Type some input to test typeahead while looping for delay... got = read(ldev, buf, 10);
<doing delay>
3456789 (finish input, echo of requested 10 chars)
Got 10 chars into buf. Trying write of buf... write(ldev, buf, got);
0123
Trying another read right away... got = read(ldev, buf, 10);
4567890123456789
Got 10 chars on second read write(ldev, buf, got);
0123
Now turning echo off-- control(ldev, ECHOCONTROL, 0);
Type some input, note lack of echoes... got = read(ldev, buf, 20);
<doing delay>
456789____________________ (input of 012345678901234567890, no echoes)
Trying write of buf... write(ldev, buf, got);
01234567890123
Asked for 20 characters; got 20
Exception 3 at EIP=00100110:
Breakpoint
Tutor> ~q OS-handled read, so interrupt-driven
Quit handler: OS-handled write, so interrupt-driven
killing process 8291 Leaving board …
#!/bin/sh
# sapc.script used for hw1 grading
# Usage: testio.sh 5 to use system 5, etc.
# shell file to test hw1 through mtip
# ~S for longer wait, ~s for shorter wait
# use 20 secs for reset, then CR, then 1 sec, then ~d, 10 secs for download
mtip -b $1 -f testio.lnx << MRK
~r~S~S
~s~S~d~S~SGO 100100
~S~s0~s~s1~s~s2~s~s3~s~s4~s~s5~s~s6~s~s7~s~s8~s~s9~s~s0~s~s1~s~s2~s~s3~s~s4~s~s5~s~s6~s~s7~s~
s8~s~s9~s~s0~s~s1~s~s2~s~s3~s~s4~s~s5~s~s6~s~s7~s~s8~s~s9~s~s0~s~s1~s~s2~s~s3~s~s4~s~s5~s~s6~
s~s7~s~s8~s~s9~s~q
MRK
read
ttyread : “program” code, dequeues from input
Q
input Q
input interrupt handler: enqueues into input Q
write ttywrite:
“program” code, enqueues to output Q
output Q echo Q
output interrupt handler: dequeues from output Q