Download An all-in-one monolithic kernel.

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

CP/M wikipedia , lookup

Security-focused operating system wikipedia , lookup

Spring (operating system) wikipedia , lookup

Copland (operating system) wikipedia , lookup

DNIX wikipedia , lookup

Distributed operating system wikipedia , lookup

Burroughs MCP wikipedia , lookup

Process management (computing) wikipedia , lookup

Thread (computing) wikipedia , lookup

Transcript
Tutorial 4
Test Practice
Q1: Which of the following is NOT an operating system theme
or model as defined in lectures?
•
•
•
•
The donkey model.
The onion model.
The manager model.
The resource allocator model.
Q2: Early Unix had what type of operating system kernel?
•
•
•
•
A client/server module kernel.
A client/server microkernel.
An all-in-one monolithic kernel.
A hybrid layered client/server kernel.
Q3: Which of the following best describes the task of a
resident monitor?
•
•
•
•
It kept several programs in memory at once and scheduled them according to time slices.
It supplied a disk operating system with spooling of input and output.
It enabled several people to use the computer at the same time from multiple terminals.
It cleared memory used by one program, automatically loaded the next program and jumped to its
starting point.
Q4: What change contributed most to the development of
time-sharing systems?
•
•
•
•
Disk drives became widely available.
Computers became cheaper.
Spooling - simultaneous peripheral operation online.
Multiple scheduling queues.
Q5: How did a time-sharing operating system
differ from a batch operating system?
• Compared to a batch system many of the
scheduling decisions could no longer be
made by the operating system.
• Time-sharing systems allowed multiple
processes to be running simultaneously.
• The response time was slower on a timesharing system.
• Security was simpler in time-sharing systems.
•
•
•
•
Q6: The first smartphone operating systems
were most similar to which of the following
types of historical operating systems?
Batch systems.
Time-sharing systems.
Hard real-time operating systems.
Resident monitors.
Q7: Which of the following is NOT a reason that virtual
machines are popular?
•
•
•
•
Multiple servers, each in its own virtual machine, can run on one computer.
Virtual machines can be easily moved from one machine to another.
Virtual machines can emulate any CPU architecture.
Virtual machines allow you to run programs from one operating system on top of another operating
system.
Q8: Which of the following was NOT included in Popek and
Goldberg’s requirements of virtualization?
•
•
•
•
Fidelity - the software should run identically on the virtual machine as on a real machine.
Performance - most instructions in the virtual machine should be run directly on the hardware.
Safety - each virtual machine, and the virtual machine monitor should be safe from actions in
another virtual machine.
Simplicity - the implementation of the virtual machine monitor must be clear and simple.
Q9: Which of the following best describes what
application virtualization is?
• An API library layer is provided which allows an
application designed to run on one operating
system to run on another operating system.
• Multiple virtual machines with the same kernel
are implemented as applications on a host
machine also running the same kernel.
• Modifications are made to the source code of an
application so that it can run efficiently on
another operating system.
• A guest operating system runs as an application
on a host operating system.
Q10: Why are spin locks particularly bad when run on a single
core processor?
•
•
•
•
Running in the spin lock is pointless as the thread holding the lock cannot run and therefore
release the lock at the same time.
Single core processors get overheated more easily if a thread is running in a spin lock.
As only one thread can run on a single core processor there is no need for a lock of any kind,
including spin locks.
Because time-slice preemption is the only way another thread can run on a single core, it is possible
for the spin lock to fail.
Q11: Which of the following is the best
definition of an atomic instruction?
• The instruction stops all other processes or
threads from working until it has completed.
• As an atomic instruction executes intermediate
states of the operand values are only accessible
from within the same process.
• Atomic instructions can only be broken down into
smaller sub-atomic instructions.
• The instruction executes without any of its
operands being visible or modifiable by outside
changes until the instruction has completed.
Q12: Which of the following statements about
the x86-64 xchg instruction is FALSE?
• It atomically swaps the values in its two
operands.
• It can be used to implement correctly working
locks.
• It can be used to atomically swap the values
of two memory locations.
• It can be used to atomically swap the values of
two registers.
Q13: How does the Bakery algorithm guarantee a unique
ordering of process requests to use a shared resource?
•
•
•
•
The ticket number distributed by the algorithm is kept unique by the use of a spin lock.
A hash value is generated from the process id of the process and the ticket number distributed by
the algorithm.
The process id of the process is appended to the ticket number distributed by the algorithm.
The algorithm uses the scheduling priority of each process as its unique ordering identifier.
Q14: Which of the following problems does not occur
as a possible consequence of locking resources?
•
•
•
•
Deadlock.
Inconsistent data.
Priority inversion.
Indefinite postponement.
Q15: What is priority inheritance?
• The solution to priority inversion, where a process using a
resource has its priority temporarily increased to that of
the highest priority process waiting for the resource.
• The solution to priority inversion, where all processes
waiting on a resource temporarily get the same priority as
the process currently using the resource.
• The solution to indefinite postponement, where a process
waiting for a resource gets the same priority as the process
currently using the resource.
• The solution to indefinite postponement, where all
processes using or waiting for a resource get the maximum
priority of all processes waiting for the resource.
Q16: Which of the following statements about
semaphores is correct?
• A semaphore is an integer count with some
indivisible operations and an initialization.
• Returning a resource when no process is
waiting causes the semaphore value to
increase.
• A binary semaphore can be used in the same
way as a simple lock.
• All of the above.
Q17: The definition “an instance of a program in
execution” best applies to which of the
following?
• a thread.
• a process.
• a user-level resource.
• a system-level resource.
Q18: Which of the following is NOT an advantage of
system-level threads over user-level threads?
• Each thread can be scheduled separately.
• Blocking threads don’t stop the entire process.
• Threads from the same process can run
simultaneously on different cores/processors.
• Switching between threads is faster.
Q19: Which of the following statements is FALSE concerning
Solaris threads before version 9?
•
•
•
•
There could be several kernel threads associated with one user-level thread at the same time.
Extra lightweight processes were added if necessary when a thread blocked in the kernel.
Several user threads could be associated with one lightweight process.
Each lightweight process was associated with one kernel thread.
Q20: With original Linux threads the clone
system call created a new process which shared
all of its memory with the original process. The
new process was then used as a thread of the
original process. Which of the following
statements was TRUE about original Linux
threads.
• If one thread called exec to run another program, all
threads in the same process would be killed.
• If one thread in the process finished, all threads
finished.
• If a thread made a blocking system call, the other
threads in the same process could still continue.
• All of the above.
Q21: Which of the following statements about the
producer/consumer problem is FALSE?
•
•
•
•
The order of data being consumed must match the order it was produced.
Each item of data produced must be consumed.
Each item of data produced must be consumed only once.
None of the above.
Q22: Which of the following statements about
multitasking is FALSE?
• Preemptive multitasking provides greater predictability
of when processes will be scheduled compared to
cooperative multitasking.
• The use of cooperative multitasking over preemptive
multitasking can make the design of the kernel simpler.
• Multitasking means that multiple processes can take
turns to execute on the same CPU in such a way that it
appears that they are all running simultaneously.
• Cooperative multitasking means that all processes
run to completion before allowing other processes to
run.
Q23: What is normally meant by a “context
switch”?
• Any change in state of a process as it executes.
• Saving the state of one process and restoring the
state of another process so that the CPU moves
from running one process to running the other.
• The switch between a process running in user
mode to running in kernel mode. This can happen
as the result of a system call or an exception.
• The change which occurs on the stack of a
running process as it makes a function call,
including the allocation of memory for any
parameters and the local variables.
Q24: Given three processes A, B, and C with
corresponding burst times 20, 5, and 2, what is
the average waiting time with a first come first
served (FCFS) scheduler? All processes are ready
to run at the same time but they arrived in the
order A, B, then C.
• 15
• 9
• 25
• 3
Here is a very simple attempt at implementing a lock:
lock:
while locked
end
locked = true
unlock:
locked = false
Q25: Which of the following statements about the above lock code is
FALSE?
• It doesn't work, multiple threads could gain the lock
simultaneously.
• It is unfair, there is no guarantee a thread will progress through the
lock.
• It doesn't work, if a thread holds the lock and goes to sleep no
other threads can gain access.
• It wastes CPU cycles checking the value of the locked variable.
Here is the lecture version of Peterson’s software solution to the two thread
lock problem:
lock:
flag[i] = true
turn = j
while (flag[j] && turn == j)
end
unlock:
flag[i] = false
Q26: Which of the following statements about this lock is FALSE?
• It can be generalized to more than two threads by simply extending the
size of the flag array.
• The lock relies on the fact that the line “turn = j” is executed atomically by
each thread.
• The lock guarantees that each thread will eventually progress past the lock
and enter the critical section of code.
• The lock will not allow one thread to enter the critical section twice if the
other thread is waiting to enter the critical section.
#include <stdio.h>
int answer = 6;
void main() {
int x = 3;
int y = 5;
printf("answer1: %d\n", answer);
__asm__("addl %1, %2\n\t"
"movl %2, %0"
: "=m" (answer)
: "r" (x),
"r" (y)
);
printf("answer2: %d\n", answer);
}
Q27: What output is produced by the second printf function in the program above?
• answer2: 6
• answer2: 2
• answer2: 8
• answer2: 5