Thread safety

A key, and unfortunately often not a clearly apparent, issue when developing multithreaded applications is that of thread safety. A thread-safe, or, as the man pages like to specify it, MT-Safe, function or API is one that can be safely executed in parallel by multiple threads with no adverse issue.

To understand what this thread-safety issue actually is, let's go back to one of the programs we saw in Appendix A, File I/O Essentials; you can find the source code within the book's GitHub repository: https://github.com/PacktPublishing/Hands-on-System-Programming-with-Linux/blob/master/A_fileio/iobuf.c. In this program, we used fopen(3) to open a file in append mode and then performed some I/O (reads/writes) upon it; we duplicate ...

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.