Chapter: Multicore Application Programming For Windows, Linux, and Oracle Solaris - Synchronization and Data Sharing

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail

Synchronization and Data Sharing

For a multithreaded application to do useful work, it is usually necessary for some kind of common state to be shared between the threads. The degree of sharing that is necessary depends on the task.

Chapter 4

Synchronization and Data Sharing

 

For a multithreaded application to do useful work, it is usually necessary for some kind of common state to be shared between the threads. The degree of sharing that is necessary depends on the task. At one extreme, the only sharing necessary may be a single number that indicates the task to be performed. For example, a thread in a web server might be told only the port number to respond to. At the other extreme, a pool of threads might be passing information constantly among themselves to indicate what tasks are complete and what work is still to be completed. Beyond sharing to coordinate work, there is sharing common data. For example, all threads might be updating a data-base, or all threads might be responsible for updating counters to indicate the amount of work completed.

 

This chapter discusses the various methods for sharing data between threads and the costs of these approaches. It starts with a discussion of data races, which are situations where multiple threads are updating the same data in an unsafe way. One way to avoid data races is by utilizing proper synchronization between threads. This chapter provides an overview of the common approaches to data sharing supported by most operating systems. This discussion focuses, as much as possible, on the abstract methods of synchro-nization and coordination. The following chapters will provide implementation-specific details for the POSIX and Windows environments.


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail


Copyright © 2018-2020 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.