Вы находитесь на странице: 1из 2

Alexandria University

Faculty of Engineering
Computer and Systems Engineering
Fall 2014

Homework 2
CS333: Operating Systems
Assigned: November 3, 2014
Due: November 12, 2014

Homework 2: Process Description and Control, Threads


1. What common events lead to the creation of a process?
2. What does it mean to preempt a process?
3. What is the difference between an interrupt and a trap?
4. What is the difference between a mode switch and a process switch?
5. Why are two modes (user and kernel) needed?
6. List reasons why a mode switch between threads may be cheaper than a mode switch between
processes.
7. What resources are typically shared by all of the threads of a process?
8. List two disadvantages of User Level Threads compared to Kernel Level Threads.
9. Figure 3.8b in the textbook (Operating Systems: Internals and Design Principles, 7th Ed) suggests
that a process can only be in one event queue at a time.
(a) Is it possible that you would want to allow a process to wait on more than one event at the
same time? Provide an example.
(b) In that case, how would you modify the queueing structure of the figure to support this new
feature? Plot an updated version of the figure to reflect your proposed solution.
10. Assume that at time 5 no system resources are being used except for the processor and memory.
Now consider the following events:
At time 5: P1 executes a command to read from disk unit 3.
At time 15: P5s time slice expires.
At time 18: P7 executes a command to write to disk unit 3.
At time 20: P3 executes a command to read from disk unit 2.
At time 24: P5 executes a command to write to disk unit 3.
At time 28: P5 is swapped out.
At time 33: An interrupt occurs from disk unit 2: P3s read is complete.
At time 36: An interrupt occurs from disk unit 3: P1s read is complete.
At time 38: P8 terminates.
At time 40: An interrupt occurs from disk unit 3: P5s write is complete.
At time 44: P5 is swapped back in.
At time 48: An interrupt occurs from disk unit 3: P7s write is complete.
For each time 22, 37, and 47, identify which state each process is in. If a process is blocked, further
identify the event on which it is blocked.

1 of 2

11. Would an algorithm that performs several independent calculations concurrently (for example
matrix multiplication) be more efficient if it used threads or if it did not use threads? Discuss this
point in both of user/kernel threads and uni/multi processors. Write down the pseudo code for
an algorithm that uses threads to do matrix multiplication.
12. Consider an environment in which there is a one-to-one mapping between user-level threads
and kernel-level threads that allows one or more threads within a process to issue blocking system calls while other threads continue to run. Explain why this model can make multithreaded
programs run faster than their single-threaded counterparts on a uniprocessor computer.
13. If a process exits and there are still threads of that process running, will they continue to run?

2 of 2

Вам также может понравиться