Summary

NSE automatically performs several operations in parallel to obtain better performance during scans. Most of the time, we won't even realize when our scripts are yielded because of this. However, there are special situations where we may need finer control over the execution of our scripts.

In this chapter, you learned all the parallelism mechanisms supported by NSE and how you can use them to control the execution flow of scripts and worker threads. We introduced Lua coroutines, showed the differences from traditional preemptive multithreading, and demonstrated how to use them to achieve collaborative multithreading. Additionally, you learned about condition variables and mutexes to control the execution flow of threads in NSE.

The next ...

Get Mastering the Nmap Scripting Engine now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.