CS439: Principles of Computer Systems
Homework 10, Part 1
Due: 8:45a Friday, April 24, 2015 Part 1 of the
homeworks must be submitted electronically. Please refer to the
homework turnin instructions.
What are the three methods of switching from user mode to
supervisor mode? When might each occur?
Given the following piece of code:
main(int argc, char**argv)
How many different copies of the variable c are there? What
are their values?
Describe the priority inversion problem and give an example
situation where it may occur.
In Unix, the pipe(2) function call creates an I/O mechanism
called a pipe and returns two file descriptors, fd and fd. The
files associated with fd and fd are streams of data and are both
opened for reading and writing. Suppose pipe always returns the two
lowest-numbered file descriptors in the process's file descriptor
table that are unused. Assume that initially fdt, the file
descriptor table, has three open entries: fdt is the default input
device, fdt is the default output device and fdt is the default
error output device; all other entries of the fdt are NULL. What does
the fdt look like after each of the five following commands is
executed in sequence by the process?
1: pipe (&fd);
When might such a sequence of commands be useful?
You'll need to use
the man pages for pipe, close, and dup to answer this question.
In two-phase commit, suppose the master fails after writing
``GLOBAL_COMMIT'' to disk and sending ``GLOBAL_COMMIT'' to all
participating nodes but before any of the nodes receive this
message. Suppose that the ``GLOBAL_COMMIT'' message reaches i of
the n participants and that the participants implement a protocol
in which they communicate with one another when they suspect the
primary has died. What is the minimum number of participants that
must receive the ``GLOBAL_COMMIT'' message to allow the
participants to complete the transaction without waiting for the
master to recover?