Exercises
111. | Carry out experiments to determine the accuracy of the performance advantages cited for transactNamedPipe. You will need to make some changes to the server code as given. Also compare the results with the current implementation. |
112. | Use the JobShell program from Chapter 6 to start the server and several clients, where each client is created using the "detached" option. Eventually, shut down the server by sending a console control event through the kill command. Can you suggest any improvements to the serverNP shutdown logic so that a connected server thread can test the shutdown flag while blocked waiting for a client request? Hint: Create a read thread similar to the connection thread. |
113. | Enhance the server so that the name of its named pipe is an argument on the command line. Bring up multiple server processes with different pipe names using the job management programs in Chapter 6. Verify that multiple clients simultaneously access this multiprocess server system. |
114. | Run the client and server on different systems to confirm correct network operation. Modify SrvrBcst (Program 11-4) so that it includes the server machine name in the named pipe. Also, modify the mailslot name used in Program 11-4. |
115. | Modify the server so that you measure the server's utilization. (In other words, what percentage of elapsed time is spent in the server?) Maintain performance information and report this information to the client on request. The Request.Command field could be used. |
116. | Enhance the server location programs so that the client will find the server with the lowest utilization rate. |
117. | Enhance the server so that the request includes a working directory. The server should set its working directory, carry out the command, and then restore the working directory to the old value. Caution: The server thread should not set the process working directory; instead, each thread should maintain a string representing its working directory and concatenate that string to the start of relative pathnames. |
118. | serverNP is designed to run indefinitely as a server, allowing clients to connect, obtain services, and disconnect. When a client disconnects, it is important for the server to free all associated resources, such as memory, file handles, and thread handles. Any remaining resource leaks will ultimately exhaust system resources, causing the server to fail, and before failure there will probably be significant performance degradation. Carefully examine serverNP to ensure that there are no resource leaks, and, if you find any, fix them. (Also, please inform the author using the e-mail address in the preface.) Note: Resource leaks are a common and serious defect in many production systems. No "industry-strength" quality assurance effort is complete if it has not addressed this issue. |
119. | Extended exercise: Synchronization objects can be used to synchronize threads in different processes on the same machine, but they cannot synchronize threads running in processes on different machines. Use named pipes and mailslots to create emulated mutexes, events, and semaphores to overcome this limitation. |
