CSCI 3000
Spring 2017
Practice Questions for Quiz 1
-
An operating system is designed in layers
- to make it more efficient.
- to make it smaller.
- to make it easier to write.
- to make it possible to handle interrupts.
Answer
A system call is typically made by
- writing a value into kernel memory.
- performing an I/O interrupt.
- performing a direct disk I/O operation.
- performing a trap.
Answer
Processors support multiple privelege levels. That means
they
- support two different instruction sets.
- restrict access to certain instructions.
- can run at two different speeds.
- support interrupts.
Answer
Which of the following instructions would need to
be privileged on a dual mode processor?
- Switch from privileged mode to user mode.
- Switch from user mode to privileged mode.
- Perform a trap.
- Read the system clock.
Answer
Which of the following does not happen when an interrupt occurs?
- The processor switches to privileged mode.
- The processor's registers are saved so that they can be restored later.
- The processor jumps to an address that is found in the interrupt vector.
- The processor resets the automatic timer to a standard value.
Answer
When a single-threaded process performs an input/output request, it
- is moved to the ready queue, and periodically asks the input/output device driver whether
the device is finished.
- is moved to the ready queue, and has its priority decreased.
- is allowed to keep running until it has used up its entire time slice.
- is put on a wait queue, and does not perform any processing until the I/O request is
satisfied.
Answer
Which of the following do two threads that are part of the same process not share?
- machine-language code.
- run-time stack.
- open files.
- process id.
Answer
The fork system call is used to
- create a new thread within a process that runs the same program as the running thread.
- create a new thread within a process that runs a different program from the running thread.
- create a new process that runs the same program as the running process.
- create a new process that runs a different program from the running processs.
Answer
Process management is typically performed by
- the operating system kernel.
- a command interpreter.
- the operating system, but above the kernel level.
- an application program on its own behalf.
Answer
The execve system call is used to
- create a new process.
- create a new thread.
- make a process run a different program.
- stop a process.
Answer
What problem is Peterson's Algorithm designed to solve?
- The critical section problem using busy-waiting.
- The critical section problem using semaphores.
- The writer-lockout problem using busy-waiting.
- The writer-lockout problem using semaphores.
Answer
Which of the following operations would most likely need to be inside a critical section?
- Fetch the value of a nonshared variable.
- Fetch the value of a shared variable.
- Reduce the value of a nonshared variable by 1.
- Reduce the value of a shared variable by 1.
Answer
Under what situation would a spin-lock be preferred over a condition variable?
- Protection of a short critical section on a single-processor machine.
- Protection of a short critical section on a multi-processor machine.
- Protection of a long critical section on a single-processor machine.
- Protection of a long critical section on a multi-processor machine.
Answer
Which of the following events would be least likely to
cause the end of a CPU burst by a running thread?
- Performing an input/output operation.
- Performing a wait on an unblocked semaphore.
- Performing a wait on a blocked semaphore.
- Waiting to receive a message from another thread.
Answer
Is it advantageous for a batch operating system to
run two or more processes simultaneously? Explain.
Answer
What is the mutual exclusion problem?
Answer
What is a mutex?
Answer
What is a condition variable? How does it differ from a mutex?
Answer
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
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