HP-UX Reference (11i v2 04/09) - 7 Device (Special) Files, 9 General Information, Index (vol 10)
g
gang_sched(7) gang_sched(7)
Gangs are scheduled for a single time-slice. The time-slice is the same for all threads in the system,
whether gang-scheduled or not.
When a single gang executes on a system, the gang’s threads are assigned to processors in the system and
are not migrated to different processors.
In an oversubscribed system with multiple gangs, all gangs are periodically moved in order to give an
equalized percentage of CPU time to each of the different threads. This rebalancing occurs every few
seconds.
EXTERNAL INFLUENCES
Environment Variables
The following environment variables affect gang scheduling of processes:
•
MP_GANG enables (when set to ON) and disables (when set to
OFF) gang scheduling of processes.
For details see the INTERFACE section of this man page.
•
MP_NUMBER_OF_THREADS
specifies the number of processors available to execute programs
compiled for parallel execution. If not set, the default is the number of processors in the system.
PERFORMANCE
Gang scheduling ensures that all runnable threads and processes in a gang are scheduled simultane-
ously. This improves the synchronization latency in parallel applications. For instance, threads waiting at
a barrier do not have to wait for currently unscheduled threads.
However, applications with lengthy parallel regions and infrequent synchronization may perform best
when not gang scheduled. For those applications, some threads can be scheduled even if all threads are
not scheduled at once.
A gang-scheduled application’s performance can be affected by the number of gang-scheduled applications
on a system, and by the number of threads in each. The gang scheduler assigns parallel applications to
CPUs using a "best fit" algorithm that attempts to minimize CPU overlap among applications.
On systems with complex workloads including gangs of varying sizes, or odd combinations of sizes, the
workload may not optimally match the number of CPUs available. In this situation an application may
perform better when not gang scheduled, thus enabling some threads to be scheduled rather than waiting
for all threads to be scheduled as a gang.
Scheduling Overhead
Gang scheduling incurs overhead when the scheduler collects a set of threads, assigns a set of processors
to the threads, and rendezvous the set of threads and processors to achieve concurrent execution.
On an idle system, the gang scheduling overhead can be seen in the execution time of a single parallel
application.
Kernel Blocking of Threads
If a thread from a gang blocks in the kernel, the thread’s processor is available to run other non-gang-
scheduled threads. When the blocked thread resumes and its gang is currently running, the thread can
join the other ganged threads without having to rendezvous again.
In a multi-gang environment, thread blocking can result in lower throughput. This occurs if an
application’s threads block often in the kernel for long periods of time.
Preempting by Realtime Threads
Gang-scheduled threads can be preempted from execution by realtime threads. This affects only the
gang-scheduled thread running on the processor being preempted by a realtime thread. The remaining
threads of the gang continue to run through the end of their time-slice.
RESTRICTIONS
For this implementation of gang scheduling, the following restrictions exist. Some of these may be
removed in future releases.
• Gang scheduling of processes being debugged is not supported. When a debugger attaches to a
process, gang scheduling for the process is disabled. This avoids gang scheduling processes with
one or more threads stopped by a debugger.
• Gang scheduling is completely shut down when Process Resource Manager (PRM) is enabled.
Section 7−−38 Hewlett-Packard Company − 2 − HP-UX 11i Version 2: September 2004