[comp.sys.m6809] semantics of read

jejones@mcrware.UUCP (James Jones) (11/11/87)

---------------------
A brief note to avoid confusion about the semantics of read():

The OS-9 read() call, like that of Nuxi, can return a count indicating that
fewer bytes than requested were read, the standard example being trying to
read more bytes than there are left in a disk file, or read past the end of
a tape.

That said, it is nonetheless still the case that read() puts the caller to
sleep until either enough bytes are ready or some error occurs while reading,
and for things such as terminal programs, file transfer programs, and the
like in OS-9, one can make profitable use of the SS_SIG and SS_RDY setstat
and getstat calls.  (I must admit to never having figured out why it is
that not having any data ready is thought to be an error (E$NRdy), but them's
the breaks.)  If you didn't grab Jim Omura's posting, you might want to.

		James Jones

jimomura@lsuc.UUCP (11/17/87)

In article <553@mcrware.UUCP> jejones@mcrware.UUCP (James Jones) writes:

...

>and for things such as terminal programs, file transfer programs, and the
>like in OS-9, one can make profitable use of the SS_SIG and SS_RDY setstat
>and getstat calls.  (I must admit to never having figured out why it is
>that not having any data ready is thought to be an error (E$NRdy), but them's
>the breaks.)  If you didn't grab Jim Omura's posting, you might want to.

     Actually, Mark Ackfield pointed out an error in my code which
could cause an occasional error due to a corrupted stack.  The
version I'm now using is as follows:

 psect gs_rdy_c,0,0,0,0,0
 nam gs_rdy_c
 ttl _gs_rdy
_gs_rdy: pshs u
 ldd #_1
 lbsr _stkcheck
 leas -2,s  Set stack pointer at "waiting"
 lda 7,s    load "path" -- actually ldd 6 and shift left 8.
 ldb #1
 os9 $8d    I$GetStt
 bcs errhand
 clra clear upper byte to make sense.
 bra cleanexit
errhand ldd #-1
cleanexit std 0,s Store the Result in    ""waiting"
* comment out next 2 lines to save program from
* crashing if interrupt occurs at this point:
* leas 2,s  Restore stack pointer.
* leas -2,s
 ldd 0,s
 leas 2,s
 puls u,pc
_1 equ -66
 endsect


Cheers -- Jim O.
-- 
Jim Omura, 2A King George's Drive, Toronto, (416) 652-3880
ihnp4!utzoo!lsuc!jimomura
Byte Information eXchange: jimomura