Go to main content
Oracle® Developer Studio 12.5: Performance Library User's Guide

Exit Print View

Updated: June 2016
 
 

Synchronization Mechanisms

One characteristic of the POSIX/Oracle Solaris threading model is that bound threads of a running application relinquish the CPUs when they are idle, thus providing good throughput and resource usage in a shared (over-subscribed) environment. By default, bound threads in a compiler-parallelized code spin-wait when they are idle, which can result in suboptimal throughput when there are other applications in the system competing for CPU resource. In this case, environment variable SUNW_MP_THR_IDLE can be used to control the behavior of a thread after it finishes its share of a parallel job:

my_host% setenv SUNW_MP_THR_IDLE value

Here, value can either be spin or sleep n s or sleep n ms , and spin is the default.

sleep puts the thread to sleep after spin-waiting n units. The wait unit can be seconds (s, the default unit) or milliseconds (ms). sleep with no arguments puts the thread to sleep immediately after completing a parallel task. If SUNW_MP_THR_IDLE contains an illegal value or is not set, spin is used as the default.

The following settings would cause threads to spin-wait (default behavior), spin for 2 seconds before sleeping, or spin for 100 milliseconds before sleeping, respectively. Using Oracle Developer Studio Performance Library routines does not change the spin-wait behavior of the code.

% setenv SUNW_MP_THR_IDLE spin
% setenv SUNW_MP_THR_IDLE 2s
% setenv SUNW_MP_THR_IDLE 100ms