CS 3733 Operating Systems, Fall 2006 Assignment 4 Comments
This assignment was graded on a basis of 30 points.
- Use symbolic values for constants. I should not see 1024 floating
around in your code.
- You cannot assume that the strings that are being sent do not include
blanks. The only character that you can assume is not embedded in
a string is the newline character.
- In get_string_list_as_lines you should create a single string
(in automatic storage) that contains all of the strings (with the
newline terminators) and use makeargv to create the list.
Otherwise, you need to worry about freeing the temporary malloc'd space.
- Simple get_string_list_as_lines outline:
#define MAX_LINE_LENGTH 1024
#define MAX_NUM_LINES 100
char linebuf[MAX_LINE_LENGTH+1];
char stringbuf[(MAX_LINE_LENGTH)(MAX_NUM_LINES + 1) + 1];
int i;
stringbuf[0] = '\0'; /* so it is a string */
for (i=0;i<MAX_NUM_LINES+1;i++) { /* extra one for empty line */
   if (get_string_as_line(fd,linebuf,MAX_LINE_LENGTH+1) <= 0) {
        handle error here
   }
   if (strlen(linebuf) == 1) {
        we are done, use makeargv with delim = "\n" and return
   strcat(stringbuf,linebuf); /* linebuf ends with a newline */
   }
}
If we get to here, there were too many lines, return an error
- In get_string_list_as_lines you can assume that valid strings
and valid lists have a maximum length but you cannot assume that
everything is valid. You should never allow a buffer overflow to occur
when strings or lists are too long.
- You can never safely do:
buf = realloc(buf,...)
because you have no way of freeing the old space if this fails since buf has been set to NULL.
You should do:
temp = realloc(buf,...)
     handle errors here
buf = temp
Testing
- It should be clear from your test output what you tested and whether it
gave the correct answers.
- If the client and server are both working you can test them together
without any additional programs. However, if they do not both work,
you might have to use a test program for each one.
- To test the client and server, they need to be run from different
directories byt need to use the same pipes.
Here is one way to set up your directory structure:
Assign4 directory:
    pipe1: FIFO
    pipe2: FIFO
    client: executable
    server: executable
    clientdir: a directory
    serverdir: a directory
Assign4/clientdir directory:
    dir: a directory containing the client files
    run the client from this directory with:
        ../client ../pipe1 ../pipe2 dir
Assign4/serverdir directory:
    dir: a directory containing the server files
    run the server from this directory with:
        ../server ../pipe2 ../pipe1