Practical Four

Circular Queue Buffers

due : 4pm 24 March 1997


Write a program to buffer keyboard input and generate an evenly-spaced stream of keystrokes.

The program must allow the user to type characters at any speed. Each character entered is displayed on the screen. However, the screen output must take place at a regular rate (say, 1 character per two seconds).

Use a circular queue to buffer the keystrokes entered until they are displayed. Implement this queue as an object, containing an array to store the keystrokes.

This type of buffer is used by the computer whenever there is disparity between the speed of input, processing and output devices. For example, the keyboard and printer have associated circular queue buffers.