CS 3733 Operating Systems, Spring 2010 Assignment 6


Due Monday, April 26, 2010


Overview
This is a continuation of Assignments 4 and 5. You will solve the same problem using network communication.

For parts 2, 3 and 4 you will be testing your program and showing the output generated. On each output test page, write a short description of why the output shows that the program was working.

Part 1
Make a directory, assign6, for this assignment and copy all of the files from assign5 into this directory. Also copy into this directory, files from Chapter 18 of USP. You can get these from the USP web site, or from your RecH directory that you created in the recitation. You will need server2p.c, client2.c, and any other files needed to compile these. You can find out which ones you need by looking at the source code (for the .h files) and the compile lines in the makefile (for the .c files).

Compile and test the server and client and make sure they can communicate.

Part 2
Write a program called search_server.c that will be a network server. It will wait for connections from a client, call searchForTwoStrings from assignment 4, and send the results back to the client. The client will send the server three lines containing the filename and the two strings, one per line in this order. The filename will be a full path specification starting with the root, not a relative path. The server will send back the return value of searchForTwoStrings as a 32-bit integer in network byte order and close the connection.
Base your server on server2p.c so that it is a parallel server. The server will take one command line parameter, the port number to listen on. Once it starts listening, it should not terminate unless it receives a signal from another process. No action of a single client should be able to make the server fail. The server should have no memory leaks or possibility of buffer overflows, no matter what a client sends it.

Write some code to test this server. Here is a possible method:
You can test this program using client2 to send it the three strings. As written, client2 will not be able to display the value it gets back from the server. One way to solve this problem is to write a filter. A filter is a program that reads from standard input and writes to standard output. Write a filter that reads a 32-bit integer in network byte order and outputs it as a string. Aside from the error checking, the body of this program only requires 2 lines of code. Test your server by having client2 pipe its output to this filter.

Part 3
Write and test program called search_tester_simple.c that takes 5 command line parameters: two strings, a filename, a hostname, and a port number. It makes a connection to the given host using the given port and sends it the strings and filename. It reports back the result of the search with an appropriate message to standard output. Show the output of the client for at least 2 cases, one in which the search was successful, and one in which it was not. Be suer to label them.

Part 4
Write and test a program called search_tester that takes 5 command line parameters: two strings, a directory name, a filename, and a port number. For each regular file in the directory it makes a connection to a search_server using the first two parameters. It gets the list of hosts to use from the 4th parameter, which will contain a list of host names, one per line. If there are more files than hosts, the hosts should be used in a round-robin fashion.
All of the connections should be made concurrently and you should return the results as they come in.
Report each result with a single line containing the file name and the result of the search. Show the output from the client when run on a directory containing both regular files and other files (directories and pipes). Include the result of ls -l on this directory and mark the regular files that contain the strings.

Describe what synchronization constructs you used to protect the critical sections that result from displaying the results.

Use this cover sheet for handing in your assignment. Answer the questions listed on the cover sheet.