CS360 Final Exam. Question 3

December 13, 1997

17 points

So, your game server in Question 2 was a big success, but the problem is that too many people are playing, and your machine is bogged down. You now want to rewrite your server so that only 20 people can play at one time. Moreover, you want to do this without modifying the game program.

One way to do this is the following: Only call accept_connection if you know that less than 20 people are playing. How can you tell if someone is done playing the game though? One way to do this is to open a pipe between the server process and each game-playing process. When the game-playing process is finished, the server can detect this because the other end of the pipe will be gone (the server can also call wait() here and get rid of zombies). Write the code to do exactly this.

You should not attempt to make this code threaded. Instead you should write it using select().