CMSC 412 Midterm #1 (Spring 1996)
  1. (15 points) Define the following terms:
    1. thread

    2. policy vs. mechanism

    3. preemptive multi-tasking

    4. critical section (three conditions)
  2. (10 points) Statement: In DOS, user programs change the hardware interrupt vector.
    1. If user programs can do this, why is it impossible to provide processor protection?

    2. Windows NT provides processor protection and can run DOS programs? Explain how this might be accomplished?

  3. (20 points) In a system that contains only one instance of each resource, circular waiting is a necessary and sufficient condition for deadlock.
    1. Why is circular waiting sufficient if there is only one instance of each resource, but only necessary if there is one instance of each resource?

    2. Consider a system with one instance of each resource, and the condition that requests for resources must be satisfied in the order in which they are received. Give an algorithm that takes as input requests to allocate and release resources and determines if the system is deadlocked.
  4. (25 points) You have to solve a variation of the readers-writers problem, in which multiple writers can write at the same time. Specifically, there are readers and writers. Multiple reads at the same time are allowed. Multiple writes at the same time are allowed. A read and a write at the same time is not allowed. Provide a solution using semaphores with the following properties:

  • (15 points) Your friend, Lazy Student, wants to test his implementation of multiplication (shown below) as a process in your kernel from assignment number two. Why might Lazy not want to run multiply(5000, 2)? Explain (in as much detail as possible) what would happen if he tried this.
    int multiply(int x, int y)
    {
    if (x == 1) {
    return(y);
    } else {
    return(y + multiply(x-1,y));
    }

    }

  • (15 points) Using test-and-set instructions, provide an algorithm that solves the dining philosophers problem. Recall that in this problem, n philosophers sit at a round table with one chop stick between each philosopher. Philosophers either are thinking or eating (rather dull people :). To eat, they need to acquire the chopsticks to their left and their right. Your solution must work for any number of philosophers and ensure that none of them starves to death.