Project 1 -- Standard I/O and POSIX I/O
Due Tuesday, September 27, 9:00 pm
(Note that due date is later than originally listed in the class
schedule.)
NOTE: This assignment, like the other projects in this class, is due
at a particular time, listed above. This means that if you are even a
minute late, you lose 20%. If you are worried about potentially being
late, turn in your project ahead of time. Do this by submitting it
electronically before the due date (the electronic copy is what is due by
the time given above) then giving the hard copy to me or the TA during
office hours or by sliding it under my office door (the hard copy is due
within twenty-four hours after the electronic copy is due). Do not send
assignments to my personal email address or to the personal email address
of the TA. Do not leave hard copies in my departmental mail box or attempt
to give them to departmental staff (who cannot and will not accept
them).
As discussed in class, there are reasons for having and using both
high-level language I/O routines and operating system I/O routines. This
assignment will involve you in using both of these.
As further discussed in class, I/O routines from both the language level
and the OS level should not be intermingled for the same file at the same
time because of possible data corruption. This assignment will investigate
this reason for by having you do exactly what you shouldn't - intermingle
these I/O routines - so that you can directly observe the consequences.
The Assignment
You are to complete several exercises regarding potential data
corruption for various combinations of input, output, language-level, and
OS-level routines. For some of these, you will write programs to
demonstrate data corruption.
- Consider following language-level output routines with OS-level output
routines for output to a regular file saved on a hard disk.
- Could this potentially cause data corruption? Explain why or
why not.
- If it could, write a program to demonstrate it. For this program,
explain whether it will always cause data corruption or may
cause data corruption.
- If your program won't always cause data corruption, run your program 10
times and report how often you see data corruption.
- Give one example of a corrupted data file resulting from running your
code.
- Consider following OS-level output routines with
language-level output routines for output to a regular file saved
on a hard disk.
- Could this potentially cause data corruption? Explain why or
why not.
- If it could, write a program to demonstrate it. For this program,
explain whether it will always cause data corruption or may
cause data corruption.
- If your program won't always cause data corruption, run your program 10
times and report how often you see data corruption.
- Give one example of a corrupted data file resulting from running your
code.
- Consider following language-level input routines with OS-level
input routines for input from a regular file saved on a hard disk.
- Could this potentially cause data corruption? Explain why or
why not.
- If it could, write a program to demonstrate it. For this program,
explain whether it will always cause data corruption or may
cause data corruption.
- If your program won't always cause data corruption, run your program 10
times and report how often you see data corruption.
- Give one example of a corrupted data file resulting from running your
code.
- Consider following OS-level input routines with
language-level input routines for input from a regular file saved on
a hard disk.
- Could this potentially cause data corruption? Explain why or
why not.
- If it could, write a program to demonstrate it. For this program,
explain whether it will always cause data corruption or may
cause data corruption.
- If your program won't always cause data corruption, run your program 10
times and report how often you see data corruption.
- Give one example of a corrupted data file resulting from running your
code.
- Consider following language-level output routines with OS-level output
routines for output to a terminal.
- Could this potentially cause data corruption? Explain why or
why not.
- If it could, write a program to demonstrate it. For this program,
explain whether it will always cause data corruption or may
cause data corruption.
- If your program won't always cause data corruption, run your program 10
times and report how often you see data corruption.
- Give one example of a corrupted data file resulting from running your
code.
- Consider following OS-level output routines with
language-level output routines for output to a terminal.
- Could this potentially cause data corruption? Explain why or
why not.
- If it could, write a program to demonstrate it. For this program,
explain whether it will always cause data corruption or may
cause data corruption.
- If your program won't always cause data corruption, run your program 10
times and report how often you see data corruption.
- Give one example of a corrupted data file resulting from running your
code.
- Consider following language-level input routines with OS-level
input routines for input from a terminal.
- Could this potentially cause data corruption? Explain why or
why not.
- If it could, write a program to demonstrate it. For this program,
explain whether it will always cause data corruption or may
cause data corruption.
- If your program won't always cause data corruption, run your program 10
times and report how often you see data corruption.
- Give one example of a corrupted data file resulting from running your
code.
- Consider following OS-level input routines with
language-level input routines for input from a terminal.
- Could this potentially cause data corruption? Explain why or
why not.
- If it could, write a program to demonstrate it. For this program,
explain whether it will always cause data corruption or may
cause data corruption.
- If your program won't always cause data corruption, run your program 10
times and report how often you see data corruption.
- Give one example of a corrupted data file resulting from running your
code.
- Consider following language-level output routines with OS-level
input routines for I/O with a regular file saved on a hard disk.
- Could this potentially cause data corruption? Explain why or
why not.
- If it could, write a program to demonstrate it. For this program,
explain whether it will always cause data corruption or may
cause data corruption.
- If your program won't always cause data corruption, run your program 10
times and report how often you see data corruption.
- Give one example of a corrupted data file resulting from running your
code.
- Consider following OS-level input routines with
language-level output routines for I/O with a regular file saved
on a hard disk.
- Could this potentially cause data corruption? Explain why or
why not.
- If it could, write a program to demonstrate it. For this program,
explain whether it will always cause data corruption or may
cause data corruption.
- If your program won't always cause data corruption, run your program 10
times and report how often you see data corruption.
- Give one example of a corrupted data file resulting from running your
code.
- Consider following language-level input routines with OS-level
output routines for I/O with a regular file saved on a hard disk.
- Could this potentially cause data corruption? Explain why or
why not.
- If it could, write a program to demonstrate it. For this program,
explain whether it will always cause data corruption or may
cause data corruption.
- If your program won't always cause data corruption, run your program 10
times and report how often you see data corruption.
- Give one example of a corrupted data file resulting from running your
code.
- Consider following OS-level output routines with
language-level input routines for I/O with a regular file saved on
a hard disk.
- Could this potentially cause data corruption? Explain why or
why not.
- If it could, write a program to demonstrate it. For this program,
explain whether it will always cause data corruption or may
cause data corruption.
- If your program won't always cause data corruption, run your program 10
times and report how often you see data corruption.
- Give one example of a corrupted data file resulting from running your
code.
Notes on this assignment
We will see later in this course that it is possible to redirect input
and output. In particular, we'll note things like redirecting standard
output to a file. However, to simplify this assignment, you do not need to
consider input and output redirection.
What to turn in.
You will turn in both a hard copy and an electronic copy of your
assignment. Please follow the instructions
on how to send electronic copies. Do not send them to my email
address.
Both the hard copy and the electronic copy will contain a write-up
giving your answers to the exercises above plus all source code you created
for these exercises. The electronic copy will also contain executables of
the programs you wrote. The electronic copy of your write-up should not be
in a proprietary format (such as MS Word); it should be either in plain
ASCII text or in a portable format (such as Postscript or PDF). Your
source code for each program should be in a single file called
exercise<X>.c
or exercise<X>.cxx
where <X>
is replaced with the appropriate exercise
number (e.g., exercise1.c
) and your executable code should be
called exercise<X>
where <X>
is again
replaced with the appropriate exercise number (e.g.,
exercise1
).
Your source code should be well structured and well commented. It
should conform to good coding standards (e.g., no memory leaks).
Your write-up will include 1/2 to 1 page (roughly 80 characters per
line, 50 lines per page) explaining the data structures and algorithms used
in your code. This page limitation does not include figures used in your
explanations, which are encouraged and may take up any amount of space.
(The explanations do not remove the requirement that your code be well
commented.)
Other
You may write your program from scratch or may start from programs for
which the source code is freely available on the web or through other
sources (such as friends or student organizations). If you do not start
from scratch, you must give a complete and accurate accounting of
where all of your code came from and indicate which parts are original or
changed, and which you got from which other source. Failure to give credit
where credit is due is academic fraud and will be dealt with
accordingly.
As noted in the syllabus, you are required to work on this programming
assignment in a group of at least two people. It is your responsibility to
find other group members and work with them. The group should turn in only
one (1) hard copy and one (1) electronic copy of the assignment. Both the
electronic and hard copies should contain the names and student ID numbers
of all group members. If your group composition changes during the
course of working on this assignment (for example, a group of five splits
into a group of two and a separate group of three), this must be clearly
indicated in your write-up, including the names and student ID numbers of
everyone involved and details of when the change occurred and who
accomplished what before and after the change.
Each group member is required to contribute equally to each project, as
far as is possible. You must thoroughly document which group members were
involved in each part of the project. For example, if you have three
functions in your program and one function was written by group member one,
the second was written by group member two, and the third was written
jointly and equally by group members three and four, both your write-up and
the comments in your code must clearly indicate this division of labor.