CS 3733 Operating Systems, Spring 2008 Recitation Sessions 11 and 12
April 11 and 18
In this session you prepare for Assignment 6.
- Create a Rec11 directory.
- Copy all of the files from your Rec10 directory
into the Rec11 directory.
If you did not do Recitation 10, download this
tar
file of the programs from Chapter 18 and untar it into your Rec11
directory.
Execute the convertlinux script.
This modifies the makefile to include -D_GNU_SOURCE
and remove the reference to -lsocket during compilation.
- Use make to compile all of the programs.
- Copy serverp.c into factor_server.c and add lines
to the makefile to compile this program.
Make sure factor_server.c can communicate with client2
as before.
- Modify factor_server.c so that instead of having the child call
copyfile it calls your function find_factors.
This function, which you will write, takes a single parameter,
the communication file descriptor for the connection.
- find_factors will read 3 long long
values from the network.
These values will be in the form of ASCII digits, high digit first,
with the numbers separated by a single blank.
You may assume that the third
number also has a trailing blank and all numbers are fewer than 20 digits.
Store these three numbers in
long long variables called n, low,
and high.
- Print these numbers out to make sure they are correct.
- Now find all factors (including repeats) of n between
low and high, inclusive.
- Print out the factors as you find them.
- Now modify the program so that it sends each factor back to the
client in the same format as it was read, as ASCII digits followed by a
blank.
When there are no more factors to be found, close the connection.
- When you think you have this working, come to the board and write your
host name and port number.
I will test your program by sending it some data.
- Make sure you sign the signout sheet before you leave, even if you
do not get your program working.