In the previous chapter, we discussed the potential pitfalls of parallel programming. One of these was synchronization overheads. As we break down work into tasks to be processed by multiple work items, there arises a need to synchronize the results from each thread. We discussed the concept of thread-local-storage and partition-local-storage, which can be used to work around this synchronization issue to a certain extent. However, it is still necessary to synchronize threads so that we can write data to a shared memory location and so that we can perform I/O operations.
In this chapter, we will discuss the synchronization primitives that are provided by the .NET Framework and the TPL.
In this chapter, we will cover the following topics:
- Synchronization primitives
- Interlocked operations
- Locking primitives
- Signaling primitives
- Lightweight synchronization...