Machine Problem 2, due Feb 25
Part of
the homework for 22C:112, Spring 2008
|
Background: The Unix read() and write() system calls are largely opaque, hiding almost all aspects of the underlying device from the programmer, but they are not entirely opaque. The challenge of this assignment is to drill down through the Unix system calls to the keyboard interface to access the keyboard status and data.
Unix provides access to device dependent behavior through the ioctl() and fcntl() system calls. The man command under the unix shell can be used to see the documentation for these system calls. In the case of read and write, you may have to type man 2 read for example, since read is also the name of a shell command.
The Assignment:
The trick to implementing these is to set the input-output mode of standard input, using some combination of ioctl() and fcntl(). The man pages for these refer to various include files in /usr/include and in /sys/usr/include that you may have to read.
Hints: /dev/tty (if used for input) is the name of the terminal. When you open a file, there is a flag word that can include a flag called O_NONBLOCK.