Skip to Main Content
Hands-On System Programming with Linux
book

Hands-On System Programming with Linux

by Kaiwan N. Billimoria, Tigran Aivazian
October 2018
Beginner content levelBeginner
794 pages
19h 23m
English
Packt Publishing
Content preview from Hands-On System Programming with Linux

Thread safety via mutex locks

Given that a function does use global and/or static variables, and the decision is to continue to use them (the second approach we mention in Table 1), obviously the places in the code where they are used constitute critical sections. As Chapter 15, Multithreading with Pthreads Part II - Synchronization, has shown in detail, we must protect these critical sections; here, we use the pthreads mutex lock to do so.

For readability, only key parts of the source code are displayed here; to view the complete source code, build and run it, the entire tree is available for cloning from GitHub: https://github.com/PacktPublishing/Hands-on-System-Programming-with-Linux.

We apply this approach the addition of a pthread ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux System Programming Techniques

Linux System Programming Techniques

Jack-Benny Persson
Linux Device Drivers, Second Edition

Linux Device Drivers, Second Edition

Jonathan Corbet, Alessandro Rubini

Publisher Resources

ISBN: 9781788998475Supplemental Content