CSCI 3000
Spring 2017
Practice Questions for Quiz 1

  1. An operating system is designed in layers

    1. to make it more efficient.
    2. to make it smaller.
    3. to make it easier to write.
    4. to make it possible to handle interrupts.

    Answer

  2. A system call is typically made by

    1. writing a value into kernel memory.
    2. performing an I/O interrupt.
    3. performing a direct disk I/O operation.
    4. performing a trap.

    Answer

  3. Processors support multiple privelege levels. That means they

    1. support two different instruction sets.
    2. restrict access to certain instructions.
    3. can run at two different speeds.
    4. support interrupts.

    Answer

  4. Which of the following instructions would need to be privileged on a dual mode processor?

    1. Switch from privileged mode to user mode.
    2. Switch from user mode to privileged mode.
    3. Perform a trap.
    4. Read the system clock.

    Answer

  5. Which of the following does not happen when an interrupt occurs?

    1. The processor switches to privileged mode.
    2. The processor's registers are saved so that they can be restored later.
    3. The processor jumps to an address that is found in the interrupt vector.
    4. The processor resets the automatic timer to a standard value.

    Answer

  6. When a single-threaded process performs an input/output request, it

    1. is moved to the ready queue, and periodically asks the input/output device driver whether the device is finished.
    2. is moved to the ready queue, and has its priority decreased.
    3. is allowed to keep running until it has used up its entire time slice.
    4. is put on a wait queue, and does not perform any processing until the I/O request is satisfied.

    Answer

  7. Which of the following do two threads that are part of the same process not share?

    1. machine-language code.
    2. run-time stack.
    3. open files.
    4. process id.

    Answer

  8. The fork system call is used to

    1. create a new thread within a process that runs the same program as the running thread.
    2. create a new thread within a process that runs a different program from the running thread.
    3. create a new process that runs the same program as the running process.
    4. create a new process that runs a different program from the running processs.

    Answer

  9. Process management is typically performed by

    1. the operating system kernel.
    2. a command interpreter.
    3. the operating system, but above the kernel level.
    4. an application program on its own behalf.

    Answer

  10. The execve system call is used to

    1. create a new process.
    2. create a new thread.
    3. make a process run a different program.
    4. stop a process.

    Answer

  11. What problem is Peterson's Algorithm designed to solve?

    1. The critical section problem using busy-waiting.
    2. The critical section problem using semaphores.
    3. The writer-lockout problem using busy-waiting.
    4. The writer-lockout problem using semaphores.

    Answer

  12. Which of the following operations would most likely need to be inside a critical section?

    1. Fetch the value of a nonshared variable.
    2. Fetch the value of a shared variable.
    3. Reduce the value of a nonshared variable by 1.
    4. Reduce the value of a shared variable by 1.

    Answer

  13. Under what situation would a spin-lock be preferred over a condition variable?

    1. Protection of a short critical section on a single-processor machine.
    2. Protection of a short critical section on a multi-processor machine.
    3. Protection of a long critical section on a single-processor machine.
    4. Protection of a long critical section on a multi-processor machine.

    Answer

  14. Which of the following events would be least likely to cause the end of a CPU burst by a running thread?

    1. Performing an input/output operation.
    2. Performing a wait on an unblocked semaphore.
    3. Performing a wait on a blocked semaphore.
    4. Waiting to receive a message from another thread.

    Answer

  15. Is it advantageous for a batch operating system to run two or more processes simultaneously? Explain.

    Answer

  16. What is the mutual exclusion problem?

    Answer

  17. What is a mutex?

    Answer

  18. What is a condition variable? How does it differ from a mutex?

    Answer

  19. Does the following code suffice to protect a critical section with two processes p0 and p1 running on separate processors on a two-processor shared-memory machine. That is, does it meet all of the requirements for protecting a critical section? The code for process p0. The code for p1 is similar, with each occurrence of 0 replaced by 1. Variable 'turn' is a shared variable.

      …  /* non-critical-section code */
    
      while(turn != 0) {}
       critical section
      turn = 0;
    
      …  /* non-critical-section code */
    

    Answer

  20. Suppose that two threads have several critical sections, protected by different mutexes. The following are two of those critical sections, with their protection code.

      code segment 1
      lock(m1);
      …  /* code protected by m1 */
      lock(m2);
      …  /* code protected by m2 */
      unlock(m2);
      unlock(m1)
    
      code segment 2
      lock(m2);
      …  /* code protected by m2 */
      lock(m1);
      …  /* code protected by m1 */
      unlock(m1);
      unlock(m2)
    

    Is that a sensible way to protected this critical code?

    Answer