Download HW1

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
no text concepts found
Transcript
Homework Assignment #1
J. H. Wang
Sep. 22, 2008
Homework #1
• Chap.2: 2.10
• Chap.3: 3.1, 3.4, 3.5* (or 3.6*)
• Chap.4: 4.6, 4.8*
• (Optional: End-of-chapter project for
Chap.4)
• Due: two weeks (Oct. 6, 2008)
• Chap.2
– 2.10: What is the main advantage for an OS designer of using a
virtual-machine architecture? What is the main advantage for a
user?
• Chap.3
– 3.1: Describe the differences among short-term, medium-term,
and long-term scheduling.
– 3.4: What are the benefits and the disadvantages of each of the
following? Consider both the system level and the programmer
level.
A. Synchronous and asynchronous communication
B. Automatic and explicit buffering
C. Send by copy and send by reference
D. Fixed-sized and variable-sized messages
– 3.5: The Fibonacci sequence is the series of numbers 0, 1, 1, 2, 3, 5,
8, … . Formally, it can be expressed as:
fib0=0
fib1=1
fibn=fibn-1+fibn-2
Write a C program using the fork() system call that generates the
Fibonacci sequence in the child process. The number of the
sequence will be provided in the command line. For example, if
5 is provided, the first five numbers in the Fibonacci sequence
will be output by the child process. Because the parent and child
processes have their own copies of the data, it will be necessary
for the child to output the sequence. Have the parent invoke the
wait() call to wait for the child process to complete before exiting
the program. Perform necessary error checking to ensure that a
non-negative number is passed on the command line.
– (3.6): Repeat the exercise in 3.5, this time using
the CreateProcess() in the Win32 API. In this
instance, you will need to specify a separate
program to be invoked from CreateProcess().
It is this separate program that will run as a
child process outputting the Fibonacci
sequence. Perform necessary error checking to
ensure that a non-negative number is passed
on the command line.
• Chap.4
– 4.6: Consider a multiprocessor system and a
multithreaded program written using the many-tomany threading model. Let the number of user-level
threads in the program to be more than the number of
processors in the system. Discuss the performance
implications of the following scenarios.
A. The number of kernel threads allocated to the
program is less than the number of processors.
B. The number of kernel threads allocated to the
program is equal to the number of processors.
C. The number of kernel threads allocated to the
program is greater than the number of processors but
less than the number of user-level threads.
– 4.8: (Similar to exercise 3.5) Write a
multithreaded program that generates the
Fibonacci series using either the Java, PThread,
or Win32 thread library.
Homework Submission
• For hand-written exercises, please turn in
your homework in paper version
• For programming exercises, please turn in
your program code via e-mail
More on End-of-Chapter Projects
• Project for Chap. 2: Adding a system call to the
Linux kernel
– Adding a new system call to the Linux kernel
– Building a new kernel
– Using the new system call from a user program
• Project for Chap. 3: UNIX shell and history
feature
– Creating a child process
– Creating a history feature
– Signal handling in UNIX
Optional End-of-Chapter Projects
• Project for Chap. 4: Matrix multiplication
– Passing parameters to each thread
– Waiting for threads to complete