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