Summary

In this chapter, we covered several safety aspects of working with threads that the powerful pthreads framework provides. We looked at thread-safe APIs, what they are, why they are required, and how to make a thread routine thread-safe. We also learned how to have one thread cancel (effectively, kill off) a given thread, and how to have the victim thread deal with any required cleanup.

The remainder of the chapter focused on how to safely mix threads with the signaling interfaces; we also compared and contrasted – giving pros and cons (some food for thought, really)—the typical multiprocess single-threaded with several processes versus multithreaded (with one process) approaches. Tips and FAQs round off this trilogy of chapters ( ...

Get Hands-On System Programming with Linux 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.