CS439: Principles of Computer Systems
Due: 7:45a Thursday, September 26, 2013 Homeworks
must be submitted electronically. Please refer to the
homework turnin instructions.
Consider a uniprocessor kernel that user programs can trap into using
system calls. The kernel receive and handles interrupts from I/O
devices. Would there be any need for critical sections within that
Describe the priority inversion problem and give an example
situation where it may occur.
Compare and contrast monitors and semaphores. What is an appropriate
use of each?
Now consider the following program fragment:
where s1 and s2 are semaphores. All variables are
automatic. Now, consider two threads running this fragment of code
simultaneously. Can there be a deadlock? Why or why not?
Some number of neighbors are sharing a bike to train for various
sporting events. Since each neighbor will train daily and also must
rest for his or her big event, they are hoping for an easy way to
share the bike that allows only one rider to be on the bike at a
time and allows the riders to rest while waiting for the bike. You
are a known expert at synchronization problems involving limited
resources, and so they have turned to you to devise a solution.
Write the following function:
which may be executed by multiple neighbors (threads) at a time,
- semaphores, and
Keep in mind that when each neighbor will need the bike is
unpredictable, and neighbors should be able to rest from the time
they request the bike until they acquire it.