Return to course page

Question 1: In class we discussed how the following code

int main(void) {
    for (int i = 0; i < N; ++i) {
        long start = get_time();
        long end = get_time();
        times[i] = end − start;
    }
}

will mostly put small times in times (a few nanoseconds), but there will be a few much larger values too (a few milliseconds). These longer times are generally caused a

  1. a trap occurring between reading start and stop

  2. a fault occurring between reading start and stop

  3. an interrupt occurring between reading start and stop

  4. an abort occurring between reading start and stop

  5. a signal occurring between reading start and stop

  6. none of the above

Question 2: (see above) Each of the following is either synchronous or asynchronous. Which are synchronous?
Select all that apply

  1. traps

  2. faults

  3. interrupts

  4. signals

Question 3: (see above) Software exceptions are most similar to which kind of hardware exception?

  1. traps

  2. faults

  3. interrupts

  4. signals

Question 4: (see above) Which of the following are true about signal handlers?
Select all that apply

  1. they run in user mode

  2. the author of one must write different code to return than in a normal function

  3. they can be executed in response to an event external to the interrupted program

  4. they can be executed in response to an invalid memory access

  5. they have extra privileges that ordinary program code does not

Question 5: (see above) Which of the following are true about exception handlers?
Select all that apply

  1. they run in user mode

  2. the author of one must write different code to return than in a normal function

  3. they can be executed in response to an event external to the interrupted program

  4. they can be executed in response to an invalid memory access

  5. they have extra privileges that ordinary program code does not.

Question 6: If process A is running, then the operating system context switches to process B. After the switch, where is the context of process A stored?

  1. on process A's stack

  2. on process B's stack

  3. in the operating system's memory

  4. in the registers of the processor

  5. in the exception table

Question 7: Suppose process A is running when the operating system context switches to process B. After the switch, where is the context of process B stored?

  1. on process A's stack

  2. on process B's stack

  3. in the operating system's memory

  4. in the registers of the processor

  5. in the exception table

Question 8: Given a call to setjmp like:

if (setjmp(env) == 0) {
    ...
} else {
    ...
}

Which of the following are saved in env?
Select all that apply

  1. the list of registered signal handlers

  2. the stack pointer

  3. copies of the values of program registers

  4. the return address of setjmp

  5. copies of the values of global variables

  6. the address space of the current process

Question 9: If an external event that would trigger an interrupt happens, but interrupts are disabled, then

  1. the interrupt handler will never run, so the OS must check for the event in another way

  2. the interrupt handler will run as soon as interrupts are enabled

  3. the interrupt handler will run because the external event reenables interrupts

Return to main page
Return to course page