CS 416 Exam 1

Fall 2010

    Part I – 31 Points

  1. 3 points
    To a programmer, a system call looks just like a function call. Explain the difference in the underlying implementation.
  2. 4 points
    Explain what is meant by chain loading.
  3. 4 points
    Is it possible to construct a secure operating system on processors that do not provide a privileged mode of operation? Explain why or why not.
  4. 4 points
    How many times does the following program print hello?
    #include <stdio.h> #include <unistd.h> main() { if (fork() == 0) printf("hello\n"); else if (fork() == 0) printf("hello\n"); printf("hello\n"); }
  5. 4 points
    What are two advantages of threads over processes?
  6. 4 points
    What is the advantage of having different time slice lengths at different levels in a multilevel feedback queue?
  7. 4 points
    What is busy waiting? How can it lead to priority inversion?
  8. 4 points
    We looked at using test & set locks to lock access to a critical section by using a shared variable:
    while (locked) ; /* loop until locked==0 */ locked = 1; /* grab the lock */ /* do critical section */ locked = 0; /* release the lock */
    Unfortunately, this was buggy because there was a race condition between getting out of the while loop and setting locked to 1. Will this code fix it? Explain why (or why not).
    wait: while (locked); if (locked == 1) goto wait; /* fix wait condition */ locked = 1; /* do critical section */ locked = 0; /* release the lock */
  9. PART II – 69 points – 3 points each

    For each statement, select the most appropriate answer. You may omit one question. Please clearly indicate the question you choose to omit.

  10. Multiprogramming (vs. multitasking) allows the operating system to:
    (a) interrupt a process to run another process.
    (b) switch execution to another process when the first process blocks on I/O or makes a system call.
    (c) allow a single process to take advantage of multiple processors.
    (d) distribute multiple processes across multiple processors in a system.
  11. A semaphore puts a thread to sleep:
    (a) if it tries to decrement the semaphore's value below 0.
    (b) if it increments the semaphore's value above 0.
    (c) until another thread issues a notify on the semaphore.
    (d) until the semaphore's value reaches a specific number.
  12. You have three processes on a system with the following performance requirements: process A runs every 90 milliseconds, using 30 milliseconds of CPU time. process B runs every 60 milliseconds, using 20 milliseconds of CPU time process C runs every 500 milliseconds, using 10 milliseconds of CPU time Use rate-monotonic analysis to assign priorities to the three processes. Assume that priorities range from 0 to 90, with 0 being the highest and that no other processes will be running on the system. Which of the following is a valid set of priority assignments?
    (a) PB=20, PA=40, PC=60
    (b) PA=5, PB=60, PC=90
    (c) PC=20, PB=40, PA=60
  13. A processor switches execution from user mode to privileged mode via (more than one answer may be correct):
    (a) a software interrupt.
    (b) a programmable I/O.
    (c) a hardware interrupt.
    (d) memory mapped I/O.
  14. Implementing preemption in operating systems relies on:
    (a) a programmable interval timer.
    (b) being able to switch to kernel mode.
    (c) having a modular operating system design.
    (d) programmable I/O.
  15. The following is not a character device:
    (a) Webcam.
    (b) Printer.
    (c) DVD.
    (d) Mouse.
  16. The master boot record (MBR):
    (a) loads the operating system from a boot partition.
    (b) loads a boot loader from a boot partition.
    (c) identifies disk partitions so the BIOS can load a boot loader from the proper partition.
    (d) contains code that is run as soon as the system is powered on or reset.
  17. Which of these is not a component of the operating system?
    (a) Boot loader.
    (b) Process scheduler.
    (c) System memory manager.
    (d) File system driver.
  18. Which component of a process is not shared across threads?
    (a) Register values.
    (b) Heap memory.
    (c) Global variables.
    (d) Program memory.
  19. The alternative to programmed I/O is:
    (a) memory-mapped I/O.
    (b) interrupt-driven I/O.
    (c) independent I/O.
    (d) direct memory access (DMA).
  20. Which is not a valid process state transition?
    (a) running ? blocked.
    (b) running ? ready.
    (c) ready ? running.
    (d) blocked ? running.
  21. A process control block (PCB) exists only for processes in:
    (a) the ready state.
    (b) ready and running states.
    (c) ready and blocked states.
    (d) ready, running, and blocked states.
  22. The memory map of a multithreaded process looks similar to that of a single-threaded process except that the multithreaded one has:
    (a) a copy of the data segment per thread.
    (b) a stack for each thread.
    (c) a heap for each thread.
    (d) a heap and stack for each thread.
  23. In a thread-aware operating system, a process control block (PCB) no longer includes:
    (a) saved registers.
    (b) process owner.
    (c) open files.
    (d) memory map.
  24. Mailboxes:
    (a) make it easy to support multiple readers.
    (b) make it possible to support multiple writers.
    (c) improve efficiency since messages do not have to copied to an intermediate entity.
    (d) all of the above.
  25. A CPU burst is:
    (a) an example of priority inversion where a low priority process gets access to the CPU.
    (b) a temporary increase in the priority of a process to ensure that it gets the CPU.
    (c) an unexpected increase in a process' need for computation.
    (d) the period of time that a process uses the processor between I/O requests.
  26. Compared to a non-preemptive scheduler, a preemptive scheduler can move processes from the:
    (a) running to the blocked state.
    (b) ready to the running state.
    (c) blocked to the ready state.
    (d) running to the ready state.
  27. A round robin scheduler:
    (a) favors processes that are expected to have a short CPU burst.
    (b) favors high priority processes.
    (c) dynamically adjusts the priority of processes based on their past CPU usage.
    (d) gives each process an equal share of the CPU.
  28. A shortest remaining time first scheduler:
    (a) dynamically adjusts the quantum based on the process.
    (b) favors processes that use the CPU for long stretches of time.
    (c) gives each process an equal share of the CPU.
    (d) tries to optimize mean response time for processes.
  29. Computing the weighted exponential average of previous CPU cycles is used for:
    (a) determining the length of a quantum for the process.
    (b) allowing a priority scheduler to assign a priority to the process.
    (c) having a round-robin scheduler sort processes in its queue.
    (d) estimating the length of the next cycle.
  30. Process aging:
    (a) helps estimate the length of the next compute period.
    (b) increases the runtime of a process.
    (c) is a count of the total CPU time used by the process and is stored in the PCB.
    (d) improves the chances of a process getting scheduled to run.
  31. Which statement about multilevel feedback queues is false? Multilevel feedback queues:
    (a) assign processes dynamically into priority classes.
    (b) give low priority processes a longer quantum.
    (c) favor interactive processes.
    (d) prioritize processes into classes based on their estimated CPU burst.
  32. A hard deadline is one:
    (a) that is difficult to estimate.
    (b) where the computation has diminishing value if it is missed.
    (c) with an unknown termination time.
    (d) that cannot be missed.