A Model Program for Performance Experimentation
The book's Web site includes a project, TimedMutualExclusion, that can be used to experiment with different boss/worker models and application program characteristics. Program features, controlled from the command line, include the following.
- The use of either a CS or a mutex lock.
- The depth, or recursion, count.
- The lock holding time, or delay, which models the amount of work done in the critical code section.
- The number of worker threads, limited only by system resources.
- The number of sleep points where a worker yields the processor, using Sleep(0), while owning the lock. Sleep points model a worker thread that waits for I/O or an event, while the delay models CPU activity.
- The number of active threads, as explained in the later section on semaphore throttles.
The delay and sleep point parameters significantly affect performance because they affect the amount of time that a worker holds a lock, preventing other workers from running.The program listing contains extensive comments explaining how to run the program and set the parameters. Exercise 91 suggests some experiments to perform on as wide a variety of systems as you can access. A variation, TimedMutualExclusionSC, supports spin counts, as explained in the next section.Note:
TimedMutualExclusion is a simple model that captures many worker thread features. It can often be tuned to represent a real application, and if the model shows performance problems, the application is at risk for similar problems. On the other hand, good performance in the model does not necessarily indicate good performance in the real application, even though the model may assist you in application performance tuning.
