void* foo(void*) { pA = new A(); B ob;
pthread_cleanup_push(reinterpret_cast<fp*>(thread_specific_destroy),pA); pthread_cleanup_pop(1);
ob.~B(); // potential problem when the thread is canceled. pthread_exit(0);
return 0;
}
int main() {
//A oa; exit(0);
//dtor for oa won’t be called if line above is uncommented. pthread_t thread_id;
for (int i = 0; i < 3; i++)
pthread_create(&thread_id, 0, &foo, 0); pthread_join(thread_id, 0);
}
NOTE: vector::clear does not free all of the memory. The storage is put back into a free pool for that one container.
This does not happen if a thread is canceled. In such cases, use thread specific data or thread local storage support along with pthread_cleanup_[pushpop] utilities.
pthread_cancel is not supported.
Function Scoping
Theset_terminate, set_unexpected, and set_new_handler, functions apply to all threads in the process. For information on specific functions, refer to the appropriate library documentation.
Performance Options
You can use
The number of string mutexes defaults to 64 and can be configured by:
export aCC_MUTEX_ARRAY_SIZE=##
You can mix code compiled with and without
Parallel Programming Using OpenMP
OpenMP is an
To view the details about the standard and details about usage, syntax and values, please go to http://www.openmp.org/drupal/node/view/8.
OpenMP Implementation
This section summarizes some of the OpenMP directives behavior that are described as
•Due to resource constraints, it is not possible for an implementation to document the maximum number of threads that can be created successfully during a program’s execution. This number is dependent upon the load on the system, the amount of memory allocated by the program, and the amount of implementation dependent stack space allocated to each thread. For a 32
Function Scoping 167