Homework 1 Solutions

22C:116, Fall 2000

Douglas W. Jones

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

  2. The Problem: Consider the following implementation of the jump buffer:
    struct jumpbuffer {
        long int pc;  /* the saved program counter */
        long int sp;  /* the saved stack pointer */
    }
    
    What assumptions must be true of the code generated by the compiler to make this definition adequate?
    1) All variables must be stored on the stack. A calling convention that allows the caller to leave local variables in registers and relies on the called routine to save and restore registers would not guarantee that, when a long jump takes place, the variables of the destination activation record would be correctly restored.

    2) There must be no frame pointer that needs restoration, or the saved stack pointer must allow recovery of both the stack pointer and frame pointer of destination activation record.

  3. Explain the difference between an interrupt and a trap, as these terms are conventionally defined. You will typically need to refer to the material covered in an undergraduate operating system or computer architecture course to find the definitions of these terms.
    An interrupt is caused by activity outside the instruction stream that the CPU is currently interpreting, such as completion of an I/O operation.

    A trap is caused by the instruction stream being interpreted, such as divide by zero or a memory access violation.