CS307
Midterm
Ondich
Due 5:00 PM, Monday, June 10, 2002

While taking this exam, you may use books, computers, the Internet, and your own brain. You may, in addition, ask Jeff Ondich questions. Otherwise, don't talk to other people about the content of the exam.

Have fun.

  1. (15 points) The Unix signal SIGSEGV often gets sent to the processes run by beginning C/C++ programmers. Perhaps you have even encountered a Segmentation Fault yourself (no doubt this was only while you were helping a CS127 student in the lab).

    Describe the circumstances under which Linux sends SIGSEGV signals to processes. You will probably want to include simple C/C++ programs that cause the errors in question, and possibly excerpts from (or references to) relevant Linux source code.

  2. (15 points) Using the POSIX threads library, write a 2-thread program for Linux. Once the thread spawning is done, the first thread (T1) should wait for user input. T1 should produce no output, but should shut down the whole process once the user types a q or a Q. T2 should take no input, but should generate a list of prime numbers starting at 2 and going as high as it can in the time allowed. From the user point of view, this program will generate primes until told to quit. From the source code point of view, there will be two independent pieces of code, each nearly trivial, and each with a separate responsibility.

    POSIX threads, also known as pthreads, are available on our Linux systems. They are documented to one degree or another in lots of places, though I have yet to find a web site that strikes me as the authoritative home of pthreads. I have written a brief "hello, world" example and tested it on prism and milner (using "g++ -Wall -o pt pt.cpp -lpthread" to compile it). You can get a list of man page topics with the command "apropos pthread". I also like the tutorial Getting Started With POSIX Threads, by Tom Wagner and Don Towsley. If you need more ideas, search the web and let me know if you find something good.

    The quality of your prime number generation is immaterial. Make it correct, but don't worry about making it fast.

  3. (3 points) I'm having back surgery in June. What movies should I watch while I'm recovering?

  4. (10 points) The Therac-25 incident is arguably the worst disaster in the history of software. You can learn all about it in An Investigation of the Therac-25 Accidents, Nancy Leveson and Clark S. Turner, IEEE Computer, Vol. 26, No. 7, July 1993, pp. 18-41. (Here's another link to the same paper.) If you wish, you may also look for other information on Therac-25 in books or on the Web.

  5. (20 points) Submit this one in a separately stapled package. You may work with other people on this exercise.

    One kind of biometric measures patterns in the timing of an individual typist's keystrokes. Studies suggest that it is very hard to mimic somebody else's keystroke timing. If this idea turns out to be reliable, it could enable us to discard passwords and instead require users to type some plain text to gain entry to their accounts.

    For this exercise, you are going to modify the Linux keyboard driver to collect very simple keystroke timing information. You should add code to the driver to collect the mean and variance of the delays between keystrokes. Don't include delays longer than .4 second. Also, create two system calls--one to reinitialize the keystroke data, and another to return the mean and variance of keystroke delays since the last initialization.