Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>libgomp</code> implements thread pools. Once created, a thread in the pool remains idle until it is signalled to become member of a thread team. After the team finishes its work, the thread goes into an idle loop until it is signalled again. The pool grows on demand but never shrinks. Threads are only signalled to exit at program finish.</p> <p>You can read the <code>libgomp</code> code that implements thread pools and teams in the 4.7.x branch <a href="http://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch/libgomp/team.c" rel="nofollow">here</a>.</p> <p>Pool threads are terminated like this: <code>libgomp</code> registers a destructor by the name of <code>team_destructor()</code>. It is called whenever the <code>main()</code> function returns, <code>exit(3)</code> gets called or the <code>libgomp</code> library is unloaded by a call to <code>dlclose(3)</code> (if previously loaded with <code>dlopen(3)</code>). The destructor deletes one <code>pthreads</code> key by the name of <code>gomp_thread_destructor</code>, which has an associated destructor function <code>gomp_free_thread()</code> triggered by the deletion. <code>gomp_free_thread()</code> makes all threads in the pool execute <code>gomp_free_pool_helper()</code> as their next task. <code>gomp_free_pool_helper()</code> calls <code>pthread_exit(3)</code> and thus all threads in the pool cease to exist.</p> <p>Here is the same process in a nice ASCII picture:</p> <pre><code>main() returns, exit() called or library unloaded | | team_destructor() deletes gomp_thread_destructor | | gomp_free_thread() called by pthreads on gomp_thread_destructor deletion | +-------------------------+---------------------------+ | | | gomp_free_pool_helper() gomp_free_pool_helper() ... gomp_free_pool_helper() installed as next task installed as next task installed as next task | | | | | | pthread_exit(NULL) pthread_exit(NULL) ... pthread_exit(NULL) </code></pre> <p>Note that this only happens once at the end of the program execution and not at the end of each <code>parallel</code> region.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload