CS-701 Midterm Exam, Spring 1996

1.

  1. Define "signal handler."
  2. Tell how the signal() system call would relate to a signal handler.
  3. Tell what causes signal handlers to be called in general.
  4. Tell what causes the function named sig_int() in Program 1.8 to be called in particular.

2.

  1. List all the processing programs that might be invoked by a compiler driver in the sequence in which they would be invoked.
  2. Give an example of a command line that would invoke all of the processing programs.
  3. Give an example of a command line that would invoke all but the last of the processing programs.
  4. Give an example of a command line that would invoke only the last of the processing programs.

3.

  1. What is the advantage of using gdb compared to the use of output statements inserted into a program.
  2. What is the advantage of using ddd compared to the use of gdb.

4. Which would take longer to execute, and why:

  1. A call to read() to read one byte of data, or a call to strcmp() to compare two 20-byte strings?
  2. A call to lseek() to move from the beginning of a 1 MB file to its end, or a call to read() executed immediately after this call to lseek()?

5. Define and describe "file descriptor" and the FILE data structure. Tell how each is used, and how the two are related to each other.

6. Tell how to define a program element so that it occupies each of the following regions of a program's address space: code, constant data, variable data, stack, heap.

7. A call to times() gives three different pieces of timing information about a process. Name and define all three.

8.

  1. How are all Unix processes created, and what is the one exception to this?
  2. Trace the process ancestry of a process that runs a command you type, such as ls. Your answer should tell what programs were executed by each process in the chain, back to the process with pid 1.

9.

  1. How can a user give a value to an environment variable from the command line?
  2. How can a user see the value of an environment variable from the command line? (There are at least two correct answers.)
  3. How can a program determine the value of an environment variable while it is executing?
  4. How does the environment variable PATH relate to the execlp() system call?


Dr. Christopher Vickery
Computer Science Department
Queens College of CUNY