Book description
Professional Multicore Programming: Design and Implementation for C++ Developers presents the basics of multicore programming in a simple, easy-to-understand manner so that you can easily apply the concepts to your everyday projects. Learn the fundamentals of programming for multiprocessor and multithreaded architecture, progress to multi-core programming and eventually become comfortable with programming techniques that otherwise can be difficult to understand. Anticipate the pitfalls and traps of concurrency programming and synchronization before you encounter them yourself by finding them outlined in this indispensable guide to multicore programming.
Table of contents
- Copyright
- About the Authors
- Credits
- Acknowledgments
- Introduction
- 1. The New Architecture
-
2. Four Effective Multicore Designs
- 2.1. The AMD Multicore Opteron
- 2.2. The Sun UltraSparc T1 Multiprocessor
- 2.3. The IBM Cell Broadband Engine
- 2.4. Intel Core 2 Duo Processor
- 2.5. Summary
-
3. The Challenges of Multicore Programming
- 3.1. What Is the Sequential Model?
- 3.2. What Is Concurrency?
-
3.3. Software Development
- 3.3.1. Challenge #1: Software Decomposition
- 3.3.2. Challenge #2: Task-to-Task Communication
- 3.3.3. Challenge #3: Concurrent Access to Data or Resources by Multiple Tasks or Agents
- 3.3.4. Challenge #4: Identifying the Relationships between Concurrently Executing Tasks
- 3.3.5. Challenge #5: Controlling Resource Contention Between Tasks
- 3.3.6. Challenge #6: How Many Processes or Threads Are Enough?
- 3.3.7. Challenges #7 and #8: Finding Reliable and Reproducible Debugging and Testing
- 3.3.8. Challenge #9: Communicating a Design That Has Multiprocessing Components
- 3.3.9. Challenge #10: Implementing Multiprocessing and Multithreading in C++
- 3.4. C++ Developers Have to Learn New Libraries
- 3.5. Processor Architecture Challenges
- 3.6. Summary
-
4. The Operating System's Role
-
4.1. What Part Does the Operating System Play?
- 4.1.1. Providing a Consistent Interface
- 4.1.2. Managing Hardware Resources and Other Software Applications
- 4.1.3. The Developer's Interaction with the Operating System
- 4.1.4. Core Operating System Services
- 4.1.5. The Application Programmer's Interface
- 4.2. Decomposition and the Operating System's Role
- 4.3. Hiding the Operating System's Role
- 4.4. Summary
-
4.1. What Part Does the Operating System Play?
-
5. Processes, C++ Interface Classes, and Predicates
- 5.1. We Say Multicore, We Mean Multiprocessor
- 5.2. What Is a Process?
- 5.3. Why Processes and Not Threads?
- 5.4. Using posix_spawn()
- 5.5. Who Is the Parent? Who Is the Child?
- 5.6. Processes: A Closer Look
- 5.7. Monitoring Processes with the ps Utility
- 5.8. Setting and Getting Process Priorities
- 5.9. What Is a Context Switch?
- 5.10. The Activities in Process Creation
- 5.11. Working with Process Environment Variables
- 5.12. Using system() to Spawn Processes
- 5.13. Killing a Process
- 5.14. Process Resources
- 5.15. What Are Asynchronous and Synchronous Processes
- 5.16. The wait() Function Call
- 5.17. Predicates, Processes, and Interface Classes
- 5.18. Summary
-
6. Multithreading
- 6.1. What Is a Thread?
- 6.2. Comparing Threads to Processes
- 6.3. Setting Thread Attributes
- 6.4. The Architecture of a Thread
- 6.5. A Simple Threaded Program
- 6.6. Creating Threads
- 6.7. Managing Threads
- 6.8. Extending the Thread Interface Class
- 6.9. Summary
-
7. Communication and Synchronization of Concurrent Tasks
-
7.1. Communication and Synchronization
- 7.1.1. Dependency Relationships
- 7.1.2. Counting Tasks Dependencies
- 7.1.3. What Is Interprocess Communication?
- 7.1.4. What Are Interthread Communications?
-
7.2. Synchronizing Concurrency
- 7.2.1. Types of Synchronization
-
7.2.2. Synchronizing Access to Data
- 7.2.2.1. Critical Sections
-
7.2.2.2. PRAM Model
- 7.2.2.2.1. Concurrent and Exclusive Memory Access
- 7.2.2.2.2. Concurrent Tasks: Coordinating Order of Execution
- 7.2.2.2.3. Relationships between Cooperating Tasks
- 7.2.2.2.4. Start-to-Start (SS) Relationship
- 7.2.2.2.5. Finish-to-Start (FS) Relationship
- 7.2.2.2.6. Start-to-Finish Relationship
- 7.2.2.2.7. Finish-to-Finish Relationship
-
7.2.3. Synchronization Mechanisms
- 7.2.3.1. Semaphores
-
7.2.3.2. Program Profile 7-4
- 7.2.3.2.1. Program Name:
- 7.2.3.2.2. Description:
- 7.2.3.2.3. Libraries Required:
- 7.2.3.2.4. Headers Required:
- 7.2.3.2.5. Compile and Link Instructions:
- 7.2.3.2.6. Test Environment:
- 7.2.3.2.7. Processors:
- 7.2.3.2.8. Execution Instructions:
- 7.2.3.2.9. Notes:
- 7.2.3.2.10. Mutex Semaphores
- 7.2.3.2.11. Using the Mutex Attribute Object
- 7.2.3.2.12. Using Mutex Semaphores to Manage Critical Sections
- 7.2.3.3. Read-Write Locks
- 7.2.3.4. Program Profile 7-5
- 7.2.3.5. Condition Variables
- 7.2.3.6. Program Profile 7-6
- 7.2.3.7. Thread-Safe Data Structures
- 7.3. Thread Strategy Approaches
- 7.4. Decomposition and Encapsulation of Work
- 7.5. Summary
-
7.1. Communication and Synchronization
-
8. PADL and PBS: Approaches to Application Design
- 8.1. Designing Applications for Massive Multicore Processors
-
8.2. What Is PADL?
-
8.2.1. Layer 5: Application Architecture Selection
- 8.2.1.1. What Are Agents?
- 8.2.1.2. What Is a Multiagent Architecture?
- 8.2.1.3. From Problem Statements to Multiagent Architectures
- 8.2.1.4. Blackboard Architectures
-
8.2.1.5. Approaches to Structuring the Blackboard
- 8.2.1.5.1. A "Question and Answer Browser" Blackboard Example
- 8.2.1.5.2. Where's the Parallelism? Where's the Blackboard?
- 8.2.1.5.3. Components of the Solution
- 8.2.1.5.4. Knowledge Sources for the Browser Program
- 8.2.1.5.5. Is a Blackboard a Good Fit?
- 8.2.1.5.6. The Blackboard as an Iterative Shared Solution Space
- 8.2.1.6. The Anatomy of a Knowledge Source
- 8.2.1.7. Concurrency Flexibility of the Application Architecture
- 8.2.2. Layer 4: Concurrency Models in PADL
-
8.2.3. Layer 3: The Implementation Model of PADL
- 8.2.3.1. C++ Components to the Rescue
- 8.2.3.2. The Intel Threading Building Blocks
-
8.2.3.3. Program Profile 8-1
- 8.2.3.3.1. Program Name:
- 8.2.3.3.2. Description:
- 8.2.3.3.3. Libraries Required:
- 8.2.3.3.4. Additional Source Files Needed:
- 8.2.3.3.5. User-Defined Headers Required:
- 8.2.3.3.6. Compile and Link Instructions:
- 8.2.3.3.7. Test Environment:
- 8.2.3.3.8. Processors:
- 8.2.3.3.9. Notes:
- 8.2.3.3.10. Obtaining the TBB library
- 8.2.3.4. The Parallel STL Library
- 8.2.3.5. The "Implementation Layer" Mapping
- 8.2.3.6. PADL: Layer 3 Type Control Strategies
-
8.2.1. Layer 5: Application Architecture Selection
- 8.3. The Predicate Breakdown Structure (PBS)
- 8.4. Summary
-
9. Modeling Software Systems That Require Concurrency
- 9.1. What Is UML?
-
9.2. Modeling the Structure of a System
- 9.2.1. The Class Model
- 9.2.2. Visualizing Classes
- 9.2.3. Ordering the Attributes and Services
- 9.2.4. Visualizing Instances of a Class
- 9.2.5. Visualizing Template Classes
- 9.2.6. Showing the Relationship between Classes and Objects
- 9.2.7. Visualizing Interface Classes
- 9.2.8. The Organization of Interactive Objects
- 9.3. UML and Concurrent Behavior
- 9.4. Visualizing the Whole System
- 9.5. Summary
-
10. Testing and Logical Fault Tolerance for Parallel Programs
- 10.1. Can You Just Skip the Testing?
- 10.2. Five Concurrency Challenges That Must Be Checked during Testing
- 10.3. Failure: The Result of Defects and Faults
-
10.4. How Do You Approach Defect Removal for Parallel Programs?
- 10.4.1. The Problem Statement
- 10.4.2. A Simple Strategy and Rough-Cut Solution Model
- 10.4.3. A Revised Solution Model Using Layer 5 from PADL
- 10.4.4. The PBS of the Agent Solution Model
-
10.5. What Are the Standard Software Engineering Tests?
- 10.5.1. Software Verification and Validation
- 10.5.2. The Code Doesn't Work — Now What?
- 10.5.3. What Is Logical Fault Tolerance?
- 10.5.4. Predicate Exceptions and Possible Worlds
- 10.5.5. What Is Model Checking?
- 10.6. Summary
- A. UML for Concurrent Design
-
B. Concurrency Models
- B.1. Interprocess and Interthread Communication
- B.2. Boss/Worker Approach 1 with Threads
- B.3. Boss/Worker Approach 1 with Processes
- B.4. Boss/Worker Approach 2 with Threads
- B.5. Boss/Worker Approach 3 with Threads
- B.6. Peer-to-Peer Approach 1 with Threads
- B.7. Peer-to-Peer Approach 1 with Processes
- B.8. Peer-to-Peer Approach 2 with Threads
- B.9. Peer-to-Peer Approach 2 with Processes
- B.10. Workpile Approach 1
- B.11. Workpile Approach 2
- B.12. Pipeline Approach with Threads
- B.13. Producer/Consumer Approach 1 with Threads
- B.14. Producer/Consumer Approach 2 with Threads
- B.15. Producer/Consumer Approach 3 with Threads
- B.16. Monitor Approach
- B.17. Blackboard Approach with Threads
- B.18. Data Level Parallelism: SIMD Approach
- B.19. Data Level Parallelism: MIMD Approach
- B.20. PRAM Model
-
C. POSIX Standard for Thread Management
- pthread_atfork()
- pthread_attr_destroy()
- pthread_attr_getdetachstate()
- pthread_attr_getguardsize()
- pthread_attr_getinheritsched()
- pthread_attr_getschedparam()
- pthread_attr_getschedpolicy()
- pthread_attr_getscope()
- pthread_attr_getstack()
- pthread_attr_getstackaddr()
- pthread_attr_getstacksize()
- pthread_attr_init()
- pthread_attr_setdetachstate()
- pthread_attr_setguardsize()
- pthread_attr_setinheritsched()
- pthread_attr_setschedparam()
- pthread_attr_setschedpolicy()
- pthread_attr_setscope()
- pthread_attr_setstack()
- pthread_attr_setstackaddr()
- pthread_attr_setstacksize()
- pthread_cancel()
- pthread_cond_broadcast()
- pthread_cond_destroy()
- pthread_cond_signal()
- pthread_cond_timedwait()
- pthread_condattr_destroy()
- pthread_condattr_getclock()
- pthread_condattr_getpshared()
- pthread_condattr_init()
- pthread_condattr_setclock()
- pthread_condattr_setpshared()
- pthread_create()
- pthread_detach()
- pthread_equal()
- pthread_exit()
- pthread_getconcurrency()
- pthread_getcpuclockid()
- pthread_getschedparam()
- pthread_getspecific()
- pthread_join()
- pthread_kill()
- pthread_mutex_destroy()
- pthread_mutex_getprioceiling()
- pthread_mutex_init()
- pthread_mutex_lock()
- pthread_mutex_setprioceiling()
- pthread_mutex_timedlock()
- pthread_mutex_trylock()
- pthread_mutexattr_destroy()
- pthread_mutexattr_getprioceiling()
- pthread_mutexattr_getprotocol()
- pthread_mutexattr_getpshared()
- pthread_mutexattr_gettype()
- pthread_mutexattr_init()
- pthread_mutexattr_setprioceiling()
- pthread_mutexattr_setprotocol()
- pthread_mutexattr_setpshared()
- pthread_mutexattr_settype()
- pthread_once()
- pthread_rwlock_destroy()
- pthread_rwlock_rdlock()
- pthread_rwlock_timedrdlock()
- pthread_rwlock_timedwrlock()
- pthread_rwlock_tryrdlock()
- pthread_rwlock_trywrlock()
- pthread_rwlock_unlock()
- pthread_rwlock_wrlock()
- pthread_rwlockattr_destroy()
- pthread_rwlockattr_getpshared()
- pthread_rwlockattr_init()
- pthread_rwlockattr_setpshared()
- pthread_self()
- pthread_setcancelstate()
- pthread_setconcurrency()
- pthread_setschedparam()
- Pthread_setschedprio()
- pthread_setspecific()
- pthread_testcancel()
-
D. POSIX Standard for Process Management
- posix_spawn()
- posix_spawn_file_actions_addclose()
- posix_spawn_file_actions_adddup2()
- posix_spawn_file_actions_addopen()
- posix_spawn_file_actions_destroy()
- posix_spawnattr_destroy()
- posix_spawnattr_getflags()
- posix_spawnattr_getpgroup()
- pisix_spawnattr_getschedparam()
- posix_spawnattr_getschedpolicy()
-
Bibliography
Product information
- Title: Professional Multicore Programming: Design and Implementation for C++ Developers
- Author(s):
- Release date: September 2008
- Publisher(s): Wrox
- ISBN: 9780470289624
You might also like
book
Practical C++ Design: From Programming to Architecture
Go from competent C++ developer to skilled designer or architect using this book as your personal …
book
Practical C++ Design: From Programming to Architecture
Go from competent C++ developer to skilled designer or architect using this book as your C++ …
book
Optimized C++
In today’s fast and competitive world, a program’s performance is just as important to customers as …
book
Modern C++: Efficient and Scalable Application Development
Create apps in C++ and leverage its latest features using modern programming techniques. Key Features Develop …