Assignment 5, due Feb. 20
Part of
the homework for 22C:112, Spring 2009
|
Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated (usually a Friday). The only exceptions to this rule will be by advance arrangement unless there is what insurance companies call "an act of God" - something outside your control. Homework must be turned in on paper and in class! Late work may be turned in to the teaching assistant's mailbox, but see the late work policy. Never push late work under someone's door!
The C standard library routine fgetc(f) returns one character read from file f. The variable f points to an open file object, where open file objects contain a device descriptor (used to specify a device when calling read(), a buffer, and a buffer pointer. The size of the buffer (call it BUFSIZE is bigger than one because calls to read() are relatively slow due to the overhead of system calls and due to the overhead of working down through the hierarchy of the file system and device interfaces.
a) Assume you are inside the operating system and have concluded that the user's call to read() involved a character sequential device such as an asynchronous communications line. Propose code for read() in this context, in terms of a low-level operating system internal routine called get(d), where d is some internal device descriptor (an object handle on an operating system device that has already been determined to be character sequential). (0.5 points)
b) Suggest code for fgetc(). (0.5 points)
If compatibility with Unix were not an issue, it would make sense to introduce an implementation hierarchy, with a low level serial port device interface that knows nothing about the data in the input or output streams and a suite of higher level device interfaces, each implemented entirely in terms of the lower level, that understands keyboards, the structure text, and various other communications protocols that can be embedded in a serial byte stream.
a) Go through the things that the termios interfaces allow you to set and identify those that relate to the high level category described above. (0.5 points)
b) In an ideal object-oriented implementation of the operating-system device interface, the idea of implementing one device class in terms of another is straightforward. Can you propose a way to attach high level devices to low-level devices in a Unix-like system interface? (0.5 points)
a) At the bare minimum, what interrupt must be disabled by each interrupt handler? (0.5 points)
b) At what point, at the earliest, is it possible to safely enable the interrupt identified in part a? (0.5 points)