

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Virginia Tech Bradley Department of Electrical and Computer Engineering ECE 3574: Applied Software Engineering Fall 2007
Submission Details The solutions for this problem set must be submitted as an electronic submission. Your submission will ideally be a zip/tar file containing the document file that contains the answers to the questions, and the relevant source files for the programming questions. The following information must be included at the top of the first page of your document: your full name, your student ID number, your email address, class (ECE 3574), title of the assignment (Homework Problem Set 4), and date of submission. You must submit the solutions using the “Digital Drop box” at the class web site 1. The file must be given a name of the following form: LAST _ FIRST _hw4.zip or LAST _ FIRST _hw4.tar. Paper and email submissions will not be accepted. All work must be submitted by the announced due date/time.
Questions Use the Homework 4 forum in the Discussion Board area of the class web site to ask questions about this assignment. Do not post questions that contain specific information about the solution.
Honor Code As stated in the syllabus, in working on problem sets, discussion and cooperative learning are allowed. However, copying or otherwise using another person’s detailed solutions to assigned problems is an honor code violation. See syllabus for details.
(^1) The class web site is accessed at http://www.learn.vt.edu/.
Solve the following problems from the Exercises of Chapter 4 of Silberschatz, Galvin, and Gagne, Operating System Concepts (the book is available online; see URL in Blackboard):
Problem 4.1. Provide two programming examples in which multithreading does not provide better performance than a single-threaded solution
Answer: (1) Any kind of sequential program is not a good candidate to be threaded. An example of this is a program that calculates an individual tax return. (2) Another example is a "shell" program such as the C-shell or Korn shell. Such a program must closely monitor its own working space such as open files, environment variables, and current working directory.
Problem 4.2 Describe the actions taken by a thread library to context switch between user-level threads.
Answer: Context switching between user threads is quite similar to switching between kernel threads, although it is dependent on the threads library and how it maps user threads to kernel threads. In general, context switching between user threads involves taking a user thread of its LWP and replacing it with another thread. This act typically involves saving and restoring the state of the registers.
Problem 4.3 Under what circumstances does a multithreaded solution using multiple kernel threads provide better performance than a single-threaded solution on a single-processor system?
Answer: When a kernel thread suffers a page fault, another kernel thread can be switched in to use the interleaving time in a useful manner. A single-threaded process, on the other hand, will not be capable of performing useful work when a page fault takes place. Therefore, in scenarios where a program might suffer from frequent page faults or has to wait for other system events, a multi-threaded solution would perform better even on a single-processor system.
Problem 4.4 Which of the following components of program state are shared across threads in a multithreaded process? a. Register values b. Heap memory c. Global variables d. Stack memory
Answer: The threads of a multithreaded process share heap memory and global variables. Each thread has its separate set of register values and a separate stack.
Problem 4.5 Can a multithreaded solution using multiple user-level threads achieve better performance on a multiprocessor system than on a single-processor system?
Answer: A multithreaded system comprising of multiple user-level threads cannot make use of the different processors in a multiprocessor system simultaneously. The operating system sees only a single process and will not schedule the different threads of the process on separate processors. Consequently, there is no performance benefit associated with executing multiple user-level threads on a multiprocessor system.