作者yet5438 (Asoul)
看板NTU-Exam
标题[试题] 101下 薛智文 作业系统
时间Wed Apr 17 22:56:24 2013
课程名称︰作业系统
课程性质︰必修
课程教师︰薛智文
开课学院:电资学院
开课系所︰资讯系
考试日期(年月日)︰2013/4/17
考试时限(分钟):180min
是否需发放奖励金:yes
(如未明确表示,则不予发放)
试题 :
This is an open-book and open-own-note exam. Please do answer with your
own SUCCINCT words in the order of question number in EXACTLY one given
answer sheet. You can answer in Chinese and keep these papers. Good luck.
1.[10%] Suppose that an engineer is designing an operating system, and decides
to use a microkernel approach in order to keep the design flexible, secure,
and reliable. After writing the operating system, the engineer decides that
the implementation requires too much messeage passing between the kernel and
one of the modules, lowering processor throughput due to frequent context
switches. As a result, the programmer decides to allow the microkernel to
share memory with this module.
Describe at least one problem with this implementation that you might bring
to the engineer's attention.
2.[10%] Peter's company has being commissioned with writing several emulators
for different gaming platforms on the PC, including the PlayStation 3 and
the PlayStation Portable. He needs to balance the usability of these emulators
with the time he takes to write these emulators. What method of virtualization
is better to implement the following system?
The PlayStation 3 runs a 3.2 GHZ Cell Processor with 6 auxiliary processors,
256 MB of RAM and a 550 MHZ Graphics Card with 256 MB of dedicated memory.
The PlayStation Portable runs a 333 MHZ Processors, 64 MB of ram, and no
Graphics Card.
3.[5%] If there is a confliction between CPU and DMU accessing memory, which
one will be given higher priority? Why?
4.[10%] What are the advantages of using thread pool instead of creating
seperate threads for servicing respective request?[5%] What can we do when
the number of requests varies a lot?[5%]
5.[10%] Netbook are a category of small, lightweight laptops (e.g. Eee PC
and Aspire One.) As the network access becomes the main usage of person
computers, the need of this kind of computer is emerging. In 2009, Google
even released Google OS, an operating system based solely on Chrome browser
which shipped in Chromebook (
http://www.google.com/intl/en/chrome/devices/)
6.[10%] You were assigned to decide a CPU scheduler for a new type of
smartphone. Please provide a reasonable solution considering ONLY that the
CPU is less powerful.[5%] What if we consider other possible feathers of
smartphone?[5%]
7.[15%] Consider a single philosopher in the Dining Philosophers problem. The
philosopher can be in only one of the three states: EATING, THINKING, and
HUNGRY. Suppose we want to schedule tasks for the philosopher to complete,
and every task can be run during one state. If the scheduler tries to run a
process that the philosopher cannot complete in her current state, then an
exception occurs and the task is returned to the back of its ready queue.
Assume that a philosopher cannot predict when she will enter a particular
state, but that she will enter every state on a regular basis.
c.[5%] Describe a scheduling algorithm that would ensure that every task is
completed within finite time (no starvation). How does your algorithm achieve
this goal?
d.[10%] Now, suppose some tasks could be completed during more than one state.
How could you improve throughput, with respect would introduce and how
you would solve it.
8. [5%] Try to use the system call 'fork()' to implement a program that
generate a child and print "Child!" and then back to the parent process and
print "Parent!"
9.[10%] You are assigned to design a program that creates several threads of
"visitors" and "cars". Visitors wander around for a random amount of time
until they decide to go on a car ride. If they are first in line for a car
ride and a car is available they take a ride, else they must wait till they
are first in line or a car comes back. If there are no visitors in line the
cars wait in order until a visitor wants to go on a ride. And in this
program, you may use queue to memory both visitors and cars line.
The pseudo code under describe the function of the visitor and car for the
thread to run:
1.visitor{
2. wandering around the park
3. join end of visitor queue
4. wait until at head of visitor queue
5. wait until there is a car free
6. remove car from car queue
7. remove self from visitor queue
8. occupy car
9. wait until not in car anymore
10.}
12.car{
13. join end of car queue
14. wait until occupied
15. give ride to the visitor
16. eject visitor from car
17.}
However, you would find something go wrong after you run the progeam.
Obviously, the error caused by many race conditions hidden inside the psuedo
code. Here are several functions to help you make all threads function
properly:
lock_c();/*lock for the car queue*/
unlock_c();/*unlock for the car queue*/
lock_v();/*lock for the visitor queue*/
unlock_v();/*unlock for the visitor queue*/
Please explain where to put there functions and why?
※Note the these function only control queues not all threads
10.[10%] None of the servers are able to address the C10k problem by using
threads. What disadvantage make threads useless for this situation? Write down
two disadvantages with brief explanation.[5%] How do you solve it?[5%]
"The C10k problem refers to the problem of optimising server software to
handle a large number of clients at the same time (hence the name C10k -
concurrent ten thousand connections). The problem of socket server
optimisation has been studied because a number of factors must be considered
to allow a web server to support many clients. This can involve a combination
of operating system constraints and server software limitations."
--From Wikipedia
11.[5%] When multiple threads run in parallel on a multicore system, would the
more threads for the same tasks always finish earlier when the number of
threads is less than the number of cores? Why?
12.Describe the problem for the following implementation of a critical
section.[10%]
do{
turn = j;
flag[i] = TRUE;
while(flag[i] && turn ==j);
critical section
flag[i]=false;
remainder section
}while(1);
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.30.130
※ 编辑: yet5438 来自: 140.112.30.130 (04/17 23:02)