Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (799.29 KB, 20 trang )
Chapter 3
cations a user decides to run. When a hardware interrupt occurs, a DOS program
can jump quickly to an interrupt-service routine. Under Windows, the operating
system has to decide which driver or virtual machine should service the interrupt
and pass control to it, all the while handling the demands of whatever other appli-
cations are running. All of that takes time, so under Windows, the interrupt
latency, or the time before an interrupt is serviced, is much longer than under
DOS, and isn't as predictable.
Code Efficiency
In addition to the programming language you use, how you write your programs
can affect execution speed. A complete discussion on how to write efficient pro-
gram code is well beyond the scope of this book, but a simple example illustrates
the issues involved:
You can generate a sine wave or other waveform by connecting a parallel port's
outputs to the inputs of a digital-to-analog converter (DAC, and writing a repeat-
ing series of bytes to the port. One way to generate the series of bytes would be to
use a Sine function to calculate the value for each point in the waveform before
writing it. Another, usually faster way is to calculate the values just once, store
them, and write the stored values in sequence to the port.
Data Compression
For the fastest data transfers, compressing the data in software can reduce the
number of bytes to write. Even though the number of port writes per second
doesn't change, the effective transmission rate (the amount of uncompressed data
sent per second) is greater. To use this method, you of course have to have soft-
ware on the receiving end that knows how to decompress what it receives. Parallel
ports in ECP mode can automatically decompress incoming data that uses ECP
mode's protocol for data compression.
Application-related Limits
The simplest I/O operations just write data from a register to the port, or read the
port into a register. But all programs have to do more than just this, and the extra
ti