Top-Rated Free Essay
Preview

CPSC 313 Introduction To Computer SystemsSummer

Satisfactory Essays
299 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
CPSC 313 Introduction To Computer SystemsSummer
CPSC 313 Introduction to Computer Systems

Summer 2014

Homework 2
1. [2] What are asynchronous, deferred, and disabled cancellation in pthreads? What makes them different?
2. What is the role of the contentionscope for pthreads? How does it affect the execution of pthreads?
3. Assume you have a system that does not provide a usleep(unsigned long usec) call to suspend the execution of the thread for a given amount of time, say in µsecs.
How would you implement this function using condition variables? (Describe your implementation in form of a C/C++ code snippet similar to the textbook.)
4. (Research Assignment) The execve system call (and variations of it) transforms the calling process into a new process by loading the given executable into memory.
(a) What happens to the file descriptors of open files?
(b) How can this behavior be controlled?
5. [3] Ten processes share a critical section implemented by using a semaphore x. Nine of these processes use the code P(x); <critical section>; V(x). However, one process erroneously uses the code V(x); <critical section>; P(x). What is the maximum number of processes that can be in the critical section at the same time?
6. [3] A customer gives the following instructions to a bank manager: Do not credit any funds to my account if the balance in my account exceeds n, and hold any debits until the balance in the account is large enough to permit the debit. Design a class in Java
(called SafeAccount, to be initialized with a given value for n) with two methods, credit and debit, that implements this type of account.

References
[1] A. Silberschatz, P. Galvin, and G. Gagne, Applied Operating Systems Concepts, John
Wiley & Sons, Inc., New York, NY, 2000.
[2] Deitel, Deitel, and Choffnes, Operating Systems, Pearson / Prentice Hall, 2004.
[3] D. M. Dhamdhere, Operating Systems, a Concept-Based Approach, McGraw Hill, 2009.

1

References: [1] A. Silberschatz, P. Galvin, and G. Gagne, Applied Operating Systems Concepts, John Wiley & Sons, Inc., New York, NY, 2000. [2] Deitel, Deitel, and Choffnes, Operating Systems, Pearson / Prentice Hall, 2004. [3] D. M. Dhamdhere, Operating Systems, a Concept-Based Approach, McGraw Hill, 2009. 1

You May Also Find These Documents Helpful