Operating System Midterm, Spring 2017


Name: ____________________________________________________

NYU Net ID: ______________________________________________

  1. The type of scheduling that gives each process an equal turn at the CPU in order is called:
    1. round-robin *
    2. first-come, first-served
    3. batch
    4. shortest job first
  2. If one process is outputting jobs to print and another is printing them, we have a:
    1. batch system
    2. interactive system
    3. producer-consumer situation *
    4. semaphore
  3. A thread can be considered a process without:
    1. any real reason to exist
    2. its own path of execution
    3. its own program counter
    4. its own pool of resources *
  4. A minimal operating system that runs virtual machines and keeps them out of each other's way is called a:
    1. Windows
    2. a hypervisor *
    3. a micro-kernel
    4. Linux
  5. What is wrong with the following C code:
                    
                    void producer(void)
                    {
                        item = produce_item()
                        up(&mutex)
                        up(&empty)
                        insert_item(item)
                        down(&mutex)
                        down(&empty)
                    }
                    
    1. 'void' is not a valid return type for a C function.
    2. the return of insert_item() is not stored.
    3. the '&' symbol is illegal in those spots.
    4. the place of the calls to up() and down() should be reversed. *
  6. In a batch system, we can often reduce average-time-to-completion by scheduling:
    1. the longest jobs first
    2. the shortest jobs first *
    3. the highest priority jobs first
    4. the most interactive jobs first
  7. A problem with shortest-first scheduling is:
    1. a long job may wait forever to get scheduled *
    2. there is no possible way to know what jobs will be short
    3. a long job may block and starve a short job of CPU time
    4. short jobs generally deserve little CPU time
  8. In scheduling, the virtue of proportionality means:
    1. tasks that have nice proportions should be scheduled first
    2. each task should get an equal proportion of the CPU
    3. tasks that the user thinks should execute quickly should execute quickly *
    4. every portion of memory should have its own task
  9. Java is unsuitable as a language for writing an OS because:
    1. it is too new
    2. Oracle has too much control over its standards
    3. it is object-oriented
    4. its garbage-collector could kick off at any moment, preventing the OS from scheduling a vital task *
  10. A hard real time system is one
    1. that is very difficult to program.
    2. where the schedule constraints simply must be met. *
    3. that consists mostly of hardware.
    4. that is schedulable.
  11. We might want to separate scheduling policy from the scheduling mechanism when
    1. we want the OS to set scheduling policy.
    2. the scheduling mechanism is too hard to get right.
    3. the scheduling policy is illegal.
    4. a parent process has information about its child processes that the OS doesn't have. *
  12. What are the loadable extensions to the OS called in UNIX?
    1. DLLs
    2. shared libraries *
    3. command-line tools
    4. micro-kernels
  13. One reason C used in this course instead of other programming languages is?
    1. because it is an old-school language
    2. tradition
    3. because it has direct access to memory *
    4. coding is easy in C
  14. If the processes appear to run simultaneously but are really sharing just one CPU then such a scenario is called?
    1. pseudo-parallelism *
    2. simultaneous-parallelism
    3. false-parallelism
    4. real-parallelism
  15. Which of the following facilities is used by UNIX for running batch jobs?
    1. Task Scheduler
    2. Cat
    3. Cron *
    4. Grep
  16. TLS and XCHG are:
    1. The names of registers on Intel chips.
    2. Assembly language instructions for checking a lock and assigning to it atomically. *
    3. Two common interrupts that occur on Intel chips.
    4. Assembly language instrucitons for Transmit Low Semaphore and eXtra CHarGe for a laptop.
  17. When a program tries to access a page that is mapped in its virtual address space but not loaded in physical memory, then
    1. the program stops executing
    2. a fatal error occurs
    3. a page fault occurs *
    4. another program will automatically get the CPU
  18. What is the ready state of a process?
    1. when process is all set to run but does not have the CPU *
    2. when process is unable to run until some task has been completed
    3. when process is using the CPU
    4. none of the above
  19. In a time-sharing operating system, when the time slot given to a process is completed, the process goes from the running state to the
    1. blocked state
    2. terminated state
    3. red state
    4. ready state *
  20. A message-passing system allows processes to:
    1. communicate with one another without resorting to shared memory. *
    2. communicate with one another using shared memory.
    3. avoid all inter-process communication problems.
    4. use hardware-level instructions to avoid race conditions.
  21. The operating system provides abstractions to?
    1. applications *
    2. device drivers
    3. the CPU
    4. none of the above
  22. Which type of memory provides the fastest access?
    1. L1 cache
    2. hardware registers *
    3. magnetic tape
    4. main memory
  23. The I/O method where a process continuously polls a device to check for I/O completion is called?
    1. direct memory access
    2. busy waiting *
    3. interrupt-driven programming
    4. none of the above
  24. What is the text-based user interface to an operating system called?
    1. a kernel
    2. a shared library
    3. a shell *
    4. a hypervisor
  25. Which of the following items are kept "per thread" in a thread based system?
    1. accounting information and address space
    2. child processes and signal handlers
    3. address space, pending alarms, and global variables
    4. program counter, registers, and stack *
  26. To obtain the services of the operating system, a user program must
    1. make a system call*
    2. use a semaphore
    3. pass a message to another process
    4. use Peterson's algorithm
  27. Which of the below is an example of non-persistent storage?
    1. magnetic disks
    2. RAM *
    3. magnetic tape
    4. flash drives
  28. In a "hybrid" thread implementation
    1. some threads are kernel level, and some are user level. *
    2. threads are "hybrids" of typical threads and of processes.
    3. threads use genetic algorithms to create new, "hybrid" threads.
    4. all of the above.
  29. All varieties of process creation ultimately come down to:
    1. a hardware interrupt.
    2. a user mouse click on an icon.
    3. a semaphore being bypassed.
    4. a running process executing a process-creation system call. *
  30. Process termination can be achieved by:
    1. normal exit
    2. error exit
    3. fatal error
    4. all of the above *
  31. System calls for file management might include:
    1. load(), execute() and abort()
    2. wait(), malloc() and load()
    3. open(), close(), and write() *
    4. kill(), time(), and chmod()
  32. A crucial point to remember about multi-processing systems is that, from the point of view of a single process, that process's behavior is
    1. batch processing oriented.
    2. determined by its critical sections.
    3. determined at the level of the machine language.
    4. nondeterministic, because it can't know how often it will get the CPU. *
  33. Sensor-node operating systems handle things like:
    1. motion detection
    2. smoke detection
    3. recording temperature changes
    4. all of the above *
  34. The UNIX kill() system call is a way for
    1. one process to terminate another process. *
    2. a process to stop its own execution.
    3. a user to exit the program they are running.
    4. all of the above.
  35. An advantage of implementing threads in the kernel is
    1. no special system calls are needed to avoid blocking.
    2. no user-level threading system is needed.
    3. clock pre-emption is available.
    4. all of the above. *
  36. What is wrong with the following C code?
                    
                    def N 10
                    s = malloc(N);
                    int i;
                    for(i = 0; i < N; i++)
                    {
                        s[i] = 'x';
                    }
                    printf(s);
                    
    1. We can't assign a character to s[i].
    2. The loop will never terminate.
    3. The C string is not properly terminated.
    4. We can't define N that way.
  37. Programming sensor-node operating systems is dominated by concerns about:
    1. an elegant user interface
    2. shortest-time first scheduling
    3. limited memory and battery life *
    4. all of the above
  38. One advantage of microkernels is
    1. an OS based on one is monolithic.
    2. a microkernel-based OS needs no other pieces than the microkernel.
    3. all device drivers, file systems, etc are in the microkernel.
    4. they reduce the number of kernel bugs. *
  39. Virtual machines have been made more popular by the importance of
    1. web hosting
    2. Java
    3. cloud computing
    4. all of the above *
  40. One difference between user mode and kernel mode is:
    1. there are certain machine-level instrucitons that can only be executed in kernel mode. *
    2. semaphores can only be set in kernel mode.
    3. only in the kernel mode can any machine language instructions be used.
    4. all GUI interactions take place in kernel mode.
  41. An advantage of user-level threads is
    1. they can make blocking system calls.
    2. individual processes can have their own scheduling algorithm. *
    3. one thread cannot block all other threads from proceeding.
    4. all of the above.
  42. Your program is running on a machine with 4 GB of memory. You want to allocate an 8 GB buffer for a video file. This is
    1. impossible.
    2. might be possible using a monitor.
    3. might be possible using interrupts.
    4. might be possible using virtual memory. *
  43. When making single-threaded code multi-threaded, one must be careful
    1. to check if the data structures accessed by several threads are "thread safe". *
    2. to place every piece of code inside a monitor.
    3. to ensure that Peterson's algorithm is employed before setting any variable.
    4. put mutexes before and after every loop.
  44. Pop-up threads
    1. "pop up" a signal whenever they are going to block.
    2. pop up the call stack as necessary to get more CPU time.
    3. pop up at random.
    4. are created at the moment they are needed. *
  45. A process that runs continually in the background on some OS is called
    1. ineffective.
    2. low priority.
    3. a daemon. *
    4. a cron job.
  46. When a single-CPU system is running multiple processes, it can create the illusion of parallelism by
    1. repeatedly switching the CPU between processes. *
    2. displaying process information as if all of them are running at once.
    3. batch processing.
    4. all of the above.
  47. A process exits with a fatal error when
    1. it tries to execute an instruction illegal in user mode.
    2. it accesses memory it does not own.
    3. it tries to divide a number by zero.
    4. all of the above. *
  48. A process could achieve exclusive access to a critical area by disabling interrupts. A downside to this technique is:
    1. it involves busy waiting.
    2. it involves multiple context switches.
    3. if the process hangs, the system is dead. *
    4. all of the above.
  49. Consider the following code:
                    
            /* N has been defined elsewhere */
            int level[N];
            int last_to_enter[N-1];
    
            void enter_region(int proc)
            {
                int lev;
                for(lev = 0; lev < (N - 1); lev++)
                {
                    level[proc] = lev;
                    last_to_enter[lev] = proc
                    int k = exists_not_equal(proc);  /* returns 0 if no such proc as k exists */
                    while((last_to_enter[lev] == proc) && k && 
                        (level[k] >= lev))
                    {
                        wait()  /* a call that puts this process to sleep */
                    }
                }
            }
                    
    This code is
    1. an example of Dijkstra's use of semaphores.
    2. an example of busy waiting with queues.
    3. a clever implementation of monitors.
    4. a multi-process implementation of Peterson's algorithm. *
  50. The code in #49 works by
    1. making sure only one process can be in any level.
    2. making sure one fewer process can enter each level. *
    3. ensuring that the last to enter gets into the critical region first.
    4. stopping one level shy of the critical region, at N - 1.
  51. A futexes are
    1. a way for threads to usually run in user space, but can involve the kernel when needed. *
    2. a future POSIX-compliant thread paradigm.
    3. futile mutexes/
    4. all of the above.
  52. An advantage of lottery scheduling is
    1. each processes is guaranteed an equal amount of CPU time.
    2. even the lowest priority processes have a shot at some CPU time. *
    3. when each process will get the CPU is known in advance.
    4. you can't win of you don't play!
  53. A good candidate for running in a batch system would be
    1. an interactive role-playing game.
    2. the program that adds up a businesses sales from each region and generates a daily financial report. *
    3. the automatic pilot on a commercial jet.
    4. all of the above.
  54. The type of scheduling that tries to allocate CPU time by user, not just by process, is called
    1. batch scheduling.
    2. guaranteed scheduling.
    3. lottery scheduling.
    4. fair-share scheduling. *
  55. With non-preemptive scheduling, a process will run until it
    1. blocks.
    2. voluntarily gives up the CPU.
    3. encounters a fatal error.
    4. all of the above. *