CS3013 Practice Mid-Term Exam

  1. Briefly describe why a micro-kernel operating system structure is a more robust than a monolithic (simple) operating system structure.

  2. What is the purpose of the process control block (PCB)? Explain the relationship between PCB size and context switch time.

  3. Four processes are ready to run. Their CPU burst times are 5, 12, 1 and 7.

    1. In what order are they run under a FCFS scheduling algorithm?
    2. What is the average waiting time?
    3. How close is this to the best average waiting time we could have had for these processes?
    4. What is the throughput in this last case?
    5. If a context switch takes .1 units, how much additional overhead would a Round-Robin (quantum = 4) scheduling algorithm add to the FCFS scheduling algorithm?

  4. Modify the SOS Dispatcher to support a class of real-time processes that get selected to run before any other normal processes. Normal processes only get to run when there are no real-time processes to run. Show any needed changes to the struct ProcessDescriptor data structure.

  5. Consider running the following psuedo-code on a Unix system:

        #include < stdio.h >
    
        int main() { 
           int *num, shm_id
    
           shm_id = shmget(502) /* get memory */
           num = (int *) shmat(shm_id) /* attach to it.  Initialize as */
           fork()
           *num = *num + 1
           printf("%d ", *num)
        } 
        

    1. What are the possible outputs?

    2. Add semcreate(), semwait() and semsignal() system calls to assure that only the output 1 2 gets printed.

  6. What is "busy waiting"? How do semaphores avoid "busy waiting"?

  7. Consider the following pseudo-code implementation of a semwait() call:

       sema[sid].count--;
       if (sema[sid].count < 0) {
          insert(sema[sid].queue, current_process);
          pd[current_process].state = BLOCKED;
          Dispatcher();
        }
    

    Why might disabling interrupts be ok ensure that there is not a race condition surrounding the modification of the count variable? How else might the OS protect count?

  8. True or False:

    1. You cannot get deadlock with semaphores.
    2. The operating system can disable interrupts to protect a critical region.
    3. A process may still be blocked indefinitely in a correct critical region solution.
    4. Peterson's solution works for 2 processes only.

  9. Consider the following variant to the two-process Peterson's solution to a critical-section problem:

       int flag[1]; /* boolean, shared, one per-process */
       int turn; /* shared */
       while(1) {
          flag[my_pid] = true;
          turn = my_pid; /* usually set to your_pid */
          while (flag[your_pid] || turn==your_pid){ /* usually an || */
          /* critical section */
          flag[my_pid] = false;
          /* remainder section */
       }
    

    Does it work? Explain why or why not.

  10. 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?


Return to the CS3013 Home Page

Send all questions to the TA mailing list.