FAQ

for

Project 4 -- IPC

NOTE: There were five words missing from Part 1 of this project. They have been added to the original assignment in red.


Q. Since we're all going to be running this on the same SMP capable machine at the end, do we need to optimize our prime sieve algorithm for prime checking? If someone forgets to shut down a child/server process combo and gets into the higher primes with something like a brute force algorithm, that's gonna kill the rest of us for CPU share.

A. You don't need to worry about optimizing your prime checking routines. The normal CPU scheduling algorithms on the UNIX machines should be enough to keep any one process from so burdening the machine that others cannot get work done (although people may notice a slow down to some extent). If there do seem to be some problems nonetheless, there are steps that the system administrator/root (Jim Summers) can take. Let's say, for instance, that someone mistakenly starts up a few dozen clients and they are all calculating at once and this causes interactive processes on the system (such as editors) to run annoyingly slowly. Not only could root suspend or terminate individual processes to bring performance up to acceptable levels for the other users, he could also change the system to scheduling per user (rather than the normal per process scheduling). This would mean that only the user who had all of the clients running at once would find it hard to get other work done and he or she could suspend or terminate his or her own processes.

On the other hand, it wouldn't be a bad idea for you to give your client and server processes low priority (high "nice" values), just to relieve any feeling of slow down that might otherwise result. (After all, in the spirit of the assignment we are supposed to be using up "wasted" clock cycles.)


Q. Should the client request another number in both cases or just in the case where a prime number is found?

A. Both.


Q. Should we initially create primeatschoolfile, missed numbers, schoolprimes, and schoolikely primes files inside or outside of our code?

A. The file primeatschoolfile should be be created outside of your code (before your run primeatschoold for the first time).

The files schoolprimes and schoollikelyprimes should be created by primeatschoold as needed when it is run.

There is no separate "missed numbers" file. The "missed numbers" are stored in the second line of the file primeatschoolfile.


Q. During the alternative read/send loop in primatschoold - Do you mean alternately read client1, c2, ..., cN then reply to c1, c2, ..., cN? Or do you mean alternately read client1, reply client1, read c2, reply c2, ..., read cN, reply cN?

A. Your server should alternate reading and replying (that is, read one message from a client, reply to that message, read the next message, reply to that message, etc.).


Q. Does SIGUSR1 come from a client or some other source?

A. The signal SIGUSR1 will come from another source. The person who started up the server will decide when to shut it down and will be responsible for sending the SIGUSR1 signal (by, for example, using the kill command at a shell prompt).


Q. What do you mean (in IPC) by valid FIFO name? What would be an invalid FIFO name?

A. An invalid FIFO name would be the same as an invalid file name -- for example, one that is too long.


Q. As I understand the program specifications, when a new number is given out by the server, it should place that in the 'missed numbers' list.

However, when another client requests a number the server should give it a number from the list, if any.

If there are multiple clients running at once, can't the server give out a number to one client (from the list) that it just gave out to another client(and put in the list)?

A. Note that when the server is running, there are two (2) "missed numbers" lists. One is in a file, the other is in memory.

When the server starts up, the list in the file is read into memory and the two lists are the same. However, when a client requests a number to factor, the server will send the first number from its "missed numbers" list in memory and remove this number from its "missed numbers" list in memory. If there are no numbers on the "missed numbers" list in memory, the server will send out a new number and add that number to the "missed numbers" list in the file. Further, when the server verifies a factor/number pair or spawns a child to check for primality, the server will remove the number from the "missed numbers" list in the file. So, once the server starts handling requests, these lists may be very different.

The only cases in which the server should give out the same number more than once are:

  1. if the server sends the number to a client, then shuts down before reading a reply from that client, then is started up again and gets a new request, and
  2. if the server sends the number to a client, then gets back a "bad factor" for that number, then gets a new request.