CS3013 Practice Mid-Term Exam

  1. We discussed four ways in which operating systems are structured. Which of these structures is easiest to extend to a distributed system? Briefly explain why.

  2. What does the operating system do at process scheduling time when no processes are ready to run? (Hint: see the Dispatcher code we went over in class.)

  3. What are the possible outputs when the following code is run on a Unix system?

       int n; /* shared global variable */
    
       main(int argc, char *argv[]) {
          n = 0;
    
          if (fork() == 0)
             n = n + 5;
          else
             n = n + 7;
          printf("n = %d\n", n);
       }
    

  4. Five processes are waiting to run. Their expected run times are 9, 6, 3, 5 and 7. In what order should they be run to minimize average waiting time? What algorithm did you use in order to schedule them? What are their average waiting times?

  5. Briefly describe why a virtual machine operating system structure is a good environment for developing new operating systems.

  6. Consider the following incomplete solution to Dinky Shell from Project 1:

    [0]	
    [1]	_A____
    [2]	if (id>0) 
    [3]	  {
    [4]	  _______
    [5]	  _______
    [6]       _______     
    [8]	  }
    [9]	else 
    [10]	  {
    [11]	  _______ 
    [12]      _______
    [13]	  }
    [14]    _______
    
    

    Indicate where each of the following pseudo-system calls should go in the above code. The first one has been done for you:

      A. id = fork();
      B. call execvp(cmd, args)
      C. call getrusage(&before)
      D. wait()
      E. print out "this is the child process"
      F. print out "this is the parent process"
      G. call getrusage(&after)
    
  7. True or False:

    1. You cannot get deadlock with semaphores.
    2. You cannot have deadlock with conditional critical regions.
    3. The operating system can disable interrupts to protect a critical region.
    4. A process may still be blocked indefinitely in a correct critical region solution.
    5. Semaphores are more commonly provided by operating systems than are monitors.


Return to the CS3013 Home Page