CS502 Practice Mid-Semester Exam

  1. Explain why a Micro-Kernel architecture is one of the easiest OS structures to extend to a distributed system.

  2. What are the various fields that need to be saved in a process control block (PCB)? Do we have to save the general purpose registers? Why or why not?

  3. In class, we noted that the Dispatcher() function does not return in the normal fashion. What did we mean by that?

  4. What are the possible outputs when the following code is compiled and run simultaneously in two separate processes on a Unix system (note that the code below is not identical to typical Unix system calls)?

        #include < stdio.h >
        #include "shm.h"		/* for our shared mem/sem primatives */
    
        int main(int argc, char *argv[]) {
          int *num;
    
          num = (int *) shmattach(502); /* attach to shared memory */
          if (num == NULL) {  /* if attach fails */
    	num = (int *) shmcreate(502, sizeof(int));  /* create shared memory */
    	*num = 0; /* initialize to 0 */
          }
          *num = *num + 1;
          printf("%d\n", *num);
    
        }
        

  5. Five processes are ready to run. Their CPU burst times are 5, 12, 1, 7 and 2. In what order are they run under a FCFS scheduling algorithm? What is the average waiting time? How close is this to the best average waiting time we could have had for these processes? What is the throughput?

  6. Modify Peterson's Solution as shown in class to properly synchronize 3 processes instead of only 2. You can add shared variables as needed.

  7. True or False:

    1. Conditional critical regions allow you to solve more synchronization problems than do semaphores.
    2. You will never get deadlock if you use semaphores.
    3. A process may still be starved in a correct critical region solution.
    4. Disabling interrupts, even by the operating system, is always a big no-no.
    5. Monitors are more commonly provided by today's operating systems than are semaphores.

  8. In the dining philosopher's solution shown in class, suppose philosopher 2 was absentminded and never let go of his left fork, even while thinking. If all the other philosophers behaved normally and kept thinking and eating, what would be the eventual outcome of the system?

  9. Modify the dining philosopher's solution shown in class to have the "odd" philosophers pick up their "left" forks first and the "even" philosophers pick up their "right" forks first. Does this solve the problem of potential deadlock?

  10. Threads are often called "lightweight" processes. Why? What is "light" about them?

  11. Fragmentation:

    1. What kind of fragmentation do we have with variable sized memory pratitions?
    2. What kind of fragmentation do we have with fixed partitions? Given N processes each in size M memory partitions how much fragmentation do we have?

  12. Consider the StartUsingProcessTable() function for the Simple Operating System that we looked at in class. Is there busy waiting? If so, why is it ok here? If not, what kind of waiting is it?

  13. Consider the following incomplete solution for a basic Unix shell:

          while (1) {
    
    [1]     _A____
    
            if (id>0) {
    
    [2]       _______     
    
    [3]       _______     
    
            } else {
    
    [4]       _______ 
    
    [5]       _______
    
    [6]       _______
            }
          }
    
    

    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. wait()
      D. print out "this is the child process"
      E. print out "this is the parent process"
      F. exit()
    

  14. Explain how a basic memory management unit works. Why is it needed?

  15. Given the template for a WaitSemaphore() system call:

    /* Do a semaphore wait on the semaphore indicated by sid */
    int WaitSemaphore(int sid) {
      /* statements a-h here */
    }
    

    Put the following statements in the right order:

    1. return 0;
    2. endif
    3. if (sema[sid].count < 0) then
    4. sema[sid].count--;
    5. pd[current_process].state = BLOCKED;
    6. if (!sema[sid].allocated) return -1;
    7. Dispatcher();
    8. insert(sema[sid].queue, current_process);

  16. Consider a paging system with the page table stored in memory:

    1. If the effective memory access time is 200 nanoseconds with paging, how long is the physical (raw) memory access time?
    2. If we add associative registers, and we have a 96 percent hit-ratio what is the effective memory access time? Assume access to the associative registers takes 10 nanoseconds.
    3. What is the worst-case effective memory access time we could have (using the associative registers from (b))? What is the best effective memory access time we could have (again, using the associative registers from (b))?

  17. Consider a system with a 10 bit physical address space divided into 128 frames. The logical address space for each process has 8 pages:

    1. How many bits are required for the frame number?
    2. How many bits are required for the page number?
    3. How many bits are in the offset?
    4. How many bits are required for a logical memory address?
    5. How big is the page table (in bits) for each process?

  18. Assume pure demand paging. Consider a process with 3 frames of memory and a reference string of 1 2 3 4 1 2 3 4

    1. How many page faults would a FIFO page replacement algorithm have?
    2. How many page faults would an LRU page replacement algorithm have?
    3. How many page faults would the optimum page replacement algorithm have?
    4. Using a working set model with a past reference time of 4, explain why the process is thrashing. What steps might the OS take to help?


Return to the 3013/502 Home Page

Send all questions to the claypool at cs.wpi.edu.