[comp.os.vms] buffered i/o count

WARNOCK@PRISM.CLEMSON.EDU (Todd Warnock) (09/16/87)

Where does BUFFERED I/O count come from ?  Does DMA affect it ?  What 
determines when it gets incremented ?  Pointers to manuals would be
appreciated.  I need to know for accounting purposes.

Todd Warnock
VAX Systems
Clemson University
Clemson, South Carolina 29634-2803

ARPA:	Warnock@Prism.Clemson.EDU
BITnet:	Warnock@Clemson

leichter@VENUS.YCC.YALE.EDU.UUCP (09/18/87)

	Where does BUFFERED I/O count come from ?  Does DMA affect it ?  What 
	determines when it gets incremented ?  Pointers to manuals would be
	appreciated.  I need to know for accounting purposes.

VMS I/O can be done using either of two mechanims:  Direct or buffered.

The direct I/O mechanism lets the I/O device read or write memory within your
process directly:  The pages are locked down into physical memory, the device
is told where they are and then told to "go".

The buffered I/O mechanism allocates a buffer in system space (charging
against the process's BYTLM quota); the I/O device is given access to the
buffer, and the data transferred is copied to/from the process's address
space.

The choice of which mechanism to use is entirely up to the writer of the
device driver.  In theory, a driver could even use different mechanisms for
different kinds of I/O requests - e.g., direct output and buffered input.  I
know of no driver that does this; I doubt any has ever been written (though
technically non-I/O QIO's like SETMODE are "direct" even for otherwise
buffered drivers).

There is no completely general principle that determines which drivers use
the direct mechanism, and which the buffered.  Disks and tapes use direct I/O;
in general, you'd expect "high-speed" devices to do so, though there are
exceptions, like the Ethernet drivers (which need to deal with link-level
encapsulation).  Terminals, line printers, and similar devices are buffered.

Writing a driver that uses direct I/O is somewhat more involved than writing
one that uses buffered I/O.

Direct I/O devices are almost certain to use DMA, but plenty of buffered
devices use it too - even many terminal interfaces.
							-- Jerry
------

GA.JPH@ISUMVS.BITNET.UUCP (09/18/87)

Todd Warnock <WARNOCK@PRISM.CLEMSON.EDU> writes:

> Where does BUFFERED I/O count come from ?  Does DMA affect it ?  What
> determines when it gets incremented ?  Pointers to manuals would be
> appreciated.  I need to know for accounting purposes.
>

The "Guide to writing a device driver" (or some such title, not having it
front of me at the moment) manual, shows how when writing a device driver
various functions (as in the $QIOW func argument) can be implemented as
buffered or direct I/O.  As a rule fast devices/operations use Direct I/O
slower devices/operations use Buffered.  For example disk devices typically
use DIO while terminal read/writes are BIO (note that [at least on our
system] terminal SETMODE,SENSEMODE, etc. are DIO, lazy coding probably).

For what it's worth, here DIOs are charged for, BIOs are free.

John Hascall
Iowa State University Computation Center
GAJPH@ISUMVS.BITNET

[The opinions expressed are strictly my own and are probably in no way
 related to any official position of ISUCC, Iowa State University, the
 State Board of Regents, the State of Iowa or any sane individual, ...
 although they could be reproduced by an infinite number of monkeys at
 an infinite number of terminals ... ]

I7100501@DBSTU1.BITNET.UUCP (09/20/87)

Todd Warnock asked:

>Where does BUFFERED I/O count come from ?  Does DMA affect it ?  What
>determines when it gets incremented ?  Pointers to manuals would be
>appreciated.  I need to know for accounting purposes.

Buffered I/O is a method (as opposed to Direct I/O) of transfering data from a
user process to the driver. Buffered I/O uses an intermediate system buffer in
non-paged pool which interacts with the process in process context and to which
the driver has access in fork context. If such a buffer is allocated for a user
process, its buffered i/o count is incremented. If the buffer is released, it
is decremented. Obviously, resources for buffered i/o are limited, so quotas
are used.

If the driver uses direct i/o, the process pages containing the user buffer
are locked in memory and the driver can access it directly. The direct i/o
count is incremented if pages are locked and decremented when released.

Normally all DMA devices uses direct i/o, whereas non-DMA devices may use
buffered i/o. The driver determines what transfer mode is used.

This and more information is in the "Guide to Writing a Device Driver".

-----------------------------------------------------------------------------
Eckart Meyer                            BITNET: I7100501@DBSTU1
Inst. f. Nachrichtentechnik             PHONE:  0531 / 391-2454
Technical University of Braunschweig    ADDR:   Schleinitzstr. 23
Germany                                            3300 Braunschweig
-----------------------------------------------------------------------------