Performance Impact
grepMP and grepMT are comparable in terms of program structure and complexity, but grepMT has the expected advantage of better performance; it is more efficient for the kernel to switch between threads than between processes. Appendix C shows that the theoretical advantage is real, especially when the files are on different disk drives. Both implementations exploit SMP systems, giving a considerable improvement in the elapsed time; threads, whether in the same process or in different processes, run in parallel on the different processors. The measured user time actually exceeds the elapsed time because the user time is the total for all the processors.There is a common misconception, however, that this sort of parallelism using either grepMP or grepMT only yields performance improvements on SMP systems. You can also gain performance when there are multiple disk drives or some other parallelism in the storage system. In such cases, multiple I/O operations to different files will run concurrently.