Homework 1

22C:116, Spring 1999

Due Friday Jan 29, 1999, in class

Douglas W. Jones

Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list!

This assignment is dominated by review questions that are not as much specific to the material in the book as they are to material you should have learned in prior courses or work experience.

  1. What is your E-mail address? (If you have more than one, give the address you'd prefer used for class purposes.)

  2. Background: In Pascal, it is legal to write a goto statement from within a function to a label in the main program, or from within a function local to a block of the program to a label within that block. This facility is commonly used for exception handling, for example, to escape from a deeply nested recursion when an error is discovered. The Problem: Write code in C or C++, using the C standard library routines setjmp() and longjmp() to demonstrate how similar control structures can be created in C or C++. Information on setjmp() and longjmp() is available in the standard reference books for C and it is available on any Unix system using the man command.

  3. The Problem: Given what you have learned about setjmp() and longjmp(), suggest how they might be implemented. Do not write code! Write a short paragraph suggesting an implementation!

  4. Write a short paragraph that distinguishes between the notion of processor, as the term is conventionally used in discussions of machine architecture, and process, as the term is conventionally used in discussions of operating systems.

  5. What is the difference between an interrupt and a trap?