Note that I will add problems to this list from time to time, but unless I warn you otherwise, only by adding entire new chapters at the end. So if you check back, tell your browser to reload the page (in case it has an old version cached) and then look and see if there are any new chapters after what used to be the last chapter with problems
forker.c
which is
linked to the web version of this homework contains a simple program
that loops three times, each time calling the fork
system
call described in section 4.3.1 of the textbook. Afterwards it
sleep
s (does nothing) for 30 seconds. Download this
file, compile it using the command
cc -o forker forker.cand then run it using the command
./forkerWhile the program is in its 30 second sleep, in a second terminal window do the command
ps xto get a listing of processes. How many processes are shown running the
./forker
command? Explain.
printf("Child Complete");has been removed. In the other variant, both that line and also the preceding line
wait(NULL);have been removed. Each of these variant programs is compiled and run in a shell terminal window. What difference might be observed between the two programs' behaviors? Explain. You are welcome to try the experiment if you would like.
notifyAll
in Figure 7.36, page 214, can
be safely changed to notify
. Also, how can that code
be changed to do fewer notifyAll
or notify
operations?
dbReading
instance variable.
Versions of the Server.java, Connection.java, and Client.java files from Figures 15.2-15.4 are in the directory ~max/MC78/2000-Fall/src/chap15/sockets/. (These versions are the ones the authors have made available on their web site. They are not identical to the ones in the book, due to bug fixes.)
First, make sure you understand how to compile and run these programs by doing so. In particular, make sure you can use telnet to access the Server. (You can use the name "localhost" rather than 127.0.0.1, or can telnet using the actual hostname, even from another machine.) Next, modify the Connection.java file (and possibly also the Server.java file) so that the server no longer prints out the date and time, but instead does the following:
Your new server won't be usable with the java Client, just with telnet. Try your new server out. Run it, and then repeatedly telnet to it. (As before, you can do so from different machines, or on the same machine using localhost.) Make sure that each time it reports the line of input that was provided the previous time, except the "First time."
Instructor: Max Hailperin