CS 3733 Operating Systems, Fall 1996 Assignment 3
- Part 1 is due on October 24
- Part 2 is due on November 7
When turning in assignments use the cover sheet that will be provided
and make sure that the cover sheet is completely filled in.
Part 1:
From PUP, section 4.1 starting on page 147:
Do all parts except for the last two (bidirectional ring and torus).
Modify the first program (called ring.c so that it starts by
printing a message to standard error in the form:
This program was written by ...
and modify the message printed out by each process so that it prints its child
process ID also:
This is process n with ID x, parent ID y, and child ID z
If the process has no child, it should print -1 for the child ID.
You can get a copy of the original ring.c that is in the text
from /usr/local/courses/cs3733/pup/ch04.
When capturing sample output do not use redirection.
This will affect the behavior of some of the programs.
Use cut and paste to pick up the output to your screen.
In preparing your packet to be handed in be sure you do the following:
- Include your makefile.
- Include source code for each part clearly labeled.
- Include lint output for each part clearly labeled.
- Describe the corrections needed to remove any lint errors.
- Include sample output from each of the parts and describe your observations.
- For ring1, how does it affect the output?
- For ring2, how does it affect the output?
- For ring3 include sample output and describe it in your own words.
Make sure you use a large enough value of the second parameter.
- For ring4 include sample output and describe how this differs
from ring3.
- For ring5 include sample output and describe how this differs from ring3.
- For the last part, call the program ring6 and include
sample output and describe the results.
Are they what was expected?
Part 2:
Write the following function:
int wait_for_news_to_come_in(char *path, char *grp, int recheck, int timeout)
The first parameter is a path to the base directory of our news system.
The second parameter is the name of a newsgroup, such as utsa.cs.3733
The third parameter is a time interval in seconds.
The last parameter is a timeout in seconds.
This function checks the given newsgroup and returns an integer status.
The possible return values are:
-1 if an error occurred
0 if the newgroup has been modified since the function was first called
1 if the newgroup did not change during the timeout period.
The funtion will get the modification time of the newsgroup and then recheck
it every recheck seconds. It returns if there has been a change
in the modification time. If no change has been detected after
timeout/recheck attempts, the function should return.
Write a driver to check to see that your function is working correctly.
Now copy ring.c into newsbiff.c and modifiy it as follows:
- newsbiff should take 4 command line parameters:
- the base news directory
- a file name
- a recheck time
- a timeout time
It should check that the correct number of command line parameters
have been given.
- newsbiff should read the file given as the second parameter
and determine the number of lines in the files.
- The number of child processes created in the ring should be the
number of lines in the file.
- Process i reads line (i-1) of the file and calls
wait_for_news_to_come_in with the newsgroup taken from line
(i-1) of the file.
This is only done by the children. The first child
is process 2 and it reads the first line of the file.
- When wait_for_news_to_come_in returns, the process prints
a message appropriate for the return value and exits. This message
should include the name of the newsgroup.
You can test your program on a subdirectory from your account since there is
nothing special about the news system that is used by this assignment.
Be prepared to demonstarte that your program actually works. Part of your grade
will be based on the method used to test your program.