Measurement Project
All of the course projects for this class will involve measurement of some kind.
This project will help you to get thinking about how to measure and evaluate
a computer system. In addition, it should help you to better understand
the relative costs of different activities in an operating system, ranging
from a simple function call up to a network access.
Below is a list of actions that you will time using the system clock.
Most of these actions are much faster than the
resolution of the system clock, so you will need to perform anywhere from
a few hundred to a few billion events in a loop so that the test
will take a measurable amount of time.
Call gettimeofday before and after the loop and subtract to get the elpased time.
For each test, experiment with the number of actions per loop until the test takes a
a few seconds, then divide by the number of loops to yield the average time.
In scientific work, it is never enough to measure a value once:
the measurement may be inherently variable, or the measuring equipment may
have its own internal variation. For this work, you should repeat each
test about ten times, and report the average and standard deviation.
To ensure consistency of results, everyone should conduct their experiments on the
machines with author's names on the first floor of Fitzpatrick. You can either walk down to the lab, or SSH into the machines. (list of names here). Write each of these
simple programs in C. If you are a little rusty on the details of Unix system
calls, you should make good use of the online Unix manuals by invoking, for
example, man 2 open to see all of the options for open().
This project may be done in pairs or singletons.
Write up your results in 1-2 pages.
This assignment is due at the beginning of class on Tuesday, Sep 11th.
- Run the command uname -a and record the output.
- Measure the time to invoke an empty function that does nothing and returns.
- Measure the time to invoke the simple system call SYS_getpid.
Hint: Invoke the getpid system call directly like this:
#include <unistd.h>
#include <syscall.h>
...
int pid = syscall(SYS_getpid);
- Measure the time to invoke the library function getpid().
Can you propose a reasonable hypothesis as to why this result is different from SYS_getpid?
- Measure the time to call gethostbyname("www.google.com").
Note: gethostbyname is quite slow, do not call it millions of times..
- Measure the time to open() and close() an existing file in /tmp.
- Measure the time to creat(), close(), and unlink() a file in /tmp.
Why are the results different than the previous step?
- Measure the time to open() a file for writing, write ten megabytes to the
file ONE BYTE at a time with many write()s, and then close() it.
- Repeat the previous experiment, keeping the total amount of data the same,
but writing two bytes, four bytes, and so on. Produce a line graph with "Write Size (bytes)"
on the X axis and "I/O Throughput (MB/s)" on the Y axis. Explain the shape of the graph.
- Observe all of the system calls performed by ls -la
by running strace ls -la.
How many total system calls are needed?
Starting with the line that looks something like this:
open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 3
...explain what ls is attempting to do, and how it does it.
(Hint: Use man again to look up the meaning of any system calls
that you do not recognize.)