Summary
This chapter was our first step towards writing multithreaded programs in C using the POSIX threading library. As part of this chapter:
- We went through the basics of the POSIX threading library, which is the main tool for writing multithreaded applications in POSIX-compliant systems.
- We explored the various properties of threads and their memory structure.
- We gave some insight about the available mechanisms for threads to communicate and share a state.
- We explained that how the memory regions available to all threads within the same process are the best way to share data and communicate.
- We talked about the kernel threads and the user-level threads and how they differ.
- We explained the joinable and detached threads and how they differ from the execution point of view.
- We demonstrated how to use the
pthread_create
andpthread_join
functions and what arguments they receive. - Examples of a race condition and a data race were demonstrated using...