Assignment title: Information
OBJECTIVES You are to write a distributed application and manage queues. Your server should be a stand-alone process that continuously awaits requests from other processes (the "clients"). All communications between the server and its clients should be done through Internet domain sockets. SPECIFICATIONS You are in Verona, Italy at the time of Romeo and Juliette. Two rival families, the Capulets and the Montagues, fight each other every time they have a chance. The city authorities are especially concerned by the ranged battles that occur day after day on the main plaza of the city. You are hired by the authorities of the city to write plaza management program ensuring (a) that no Capulet will enter the plaza when Montagues are present and (b) that no Montague will do the same when Capulets are present. Since the city is small, you can safely assume that plaza will never be overcrowded. THE CLIENT PART Your program will read is input line by line, respecting the prescribed time delays and fork one process per arriving Capulet or Montague. It will then send a message to the server as in: char arrival, char* person, char* family to tell the server that a person, who is member of the family family, wants to enter the plaza and ask the permission for that person to enter the plaza. After the prescribed delay, it will send a second message: char departure, char* person, char* family to tell the server that the person is leaving the plaza. Input Format: Your program should read its input from stdin. This input will look like: Capulet Marco 0 7 Capulet Guido 3 10 Montague Andrea 8 15 where the first argument is either Capulet or Montague, the second argument is a name, the third argument is an arrival time expressed in seconds and the fourth argument is the amount of time the individual will stay in the plaza, once he or she has gained entry, expressed in seconds. So the first line of the sample input read as "Capulet Marco arrives a time 0 at the plaza and leaves after having been on the plaza for 7 seconds." You can safely assume that (a) arrival times will always be monotonically increasing and (b) the input data will always be correct. Output Specifications: Your program should print out a single line each time a Capulet or Montaigu (a) arrives at the plaza, (b) gains access to the plaza or (c) leaves the plaza. As an example, the output corresponding to the sample input above should be Capulet Marco arrives Capulet Marco enters the plaza Capulet Guido arrives Capulet Guido enters the plaza Montague Andrea arrives Capulet Marco leaves the plaza Capulet Guido leaves the plaza Montague Andrea enters the plaza Montague Andrea leave the plaza THE SERVER PART The server will delay entry to the plaza each time granting access would cause trouble. It will maintain separate counts of the Capulets and Montagues who are in the plaza and separate queues for the Capulets and Montagues waiting to enter the plaza. HINTS 1. To obtain credit for this assignment, you must use Berkeley UNIX sockets in the Internet domain. 2. Refer to "BSD Sockets: A Quick and Dirty Primer" at URL: or through the course resource page. It contains a general introduction to sockets. You can include any code from that document in your assignment. 3. Use a single-threaded server to avoid critical sections inside the server. 4. Since your server will not fork any child processes, you should not worry about handling zombies and can safely ignore the fireman() call in the primer. 5. The easiest way to delay a client is to delay the server's reply to that client. 6. Do not create your child processes ahead of time and terminate them as soon as the person they represent leaves the plaza to limit the number of concurrently running processes. 7. Yes, you will have to turn in two different programs, namely a client program and a server program. This document was updated last on Wednesday, July 01, 2015. Please check the course web site for possible updates and corrections.