CS3013 Practice First 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 simple operating system code we have been looking at in class. The TimerInterruptHandler() function is invoked whenver the timer goes off (every 100 milliseconds). Assume one process running in the system. The process has a CPU burst of 150 milliseconds followed by an I/O wait of 200 milliseconds. The process repeats its CPU-I/O for 3 iterations and then terminates. Assume each instruction takes 10 microseconds to execute. Assume handling the I/O interrupt takes the same amount of time as handling the timer interrupt.

  7. Consider the following incomplete solution to Tiny 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(&rusage)
      D. call nice()
      E. wait()
      F. print out "this is the child process"
      G. print out "this is the parent process"
    

Return to the CS3013 Home Page