CS439: Principles of Computer Systems
Homework 9, Part 1
Due: 9:45a Thursday, November 13, 2014 Part 1 of the
homeworks must be submitted electronically. Please refer to the
homework turnin instructions.
In Unix, the pipe(fd) 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.
Which file allocation scheme that we studied is most similar to paging?
Jane would like to append data to the file
/usr/jane/classes/cs439/exam_study_notes.txt. Assuming she has
the correct permissions, describe the steps the operating system
would need to take to append the data.
Using the traceroute command, trace the hops a packet takes
from one of the UTCS machines to a website in Europe. Inspect the
trace. What do you notice? Do you see any machines you recognize?
ISPs? Cities? Please be sure to tell us what website you used.
Perform the trace again. How does the second time affect the output?
System Calls vs. Procedure Calls:
How much more expensive is a system call than a procedure call? Write
a simple test program to compare the cost of a simple procedure call
to a simple system call ("getuid()" is a good candidate on
UNIX; see the man page.) (Note: be careful to prevent the optimizing
compiler from "optimizing out" your procedure calls. Do not
compile with optimization on. Also, do not use a system call within your
- Explain the difference (if any) between the time required by your
simple procedure call and simple system call by discussing what work
each call must do (be specific). [Note: Do not provide the source code
for your program, just the results].
Hint: You should use system calls such as gethrtime()
or gettimeofday() for time measurements. Design your code such
that the measurement overhead is negligible. Also, be aware that timer
values in some systems have limited resolution (e.g., millisecond