|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.realtime.AffinitySet
public class AffinitySet
AffinitySet profides APIs that permit access to the set of Processors a Thread or BoundAsyncEventHandler is permitted to run on. It also provides APIs to be informed of changes in the number of CPUs available for the Java VM.
An instance of AffinitySet is an immutable set of processors. The processors are identified by integer numbers with a platform-dependend meaning.
An AffinitySet can be set to be used by a Thread or a BoundAsyncEventHandler. This setting is modifyable at runtime.
Affinity sets containing more than one processor are only supported for pre-defined affinity sets provided by the VM. getPredefinedAffinitySets() returns an array of all these predefined sets.
Changes of the number of CPUs available may cause cause failures such as deadlocks. Therefore, dynamically enabling or disabling CPUs should be disabled, at least for those CPUs used for RTSJ threads.
For JamaicaVM, the processors ids correspond to the processor ids that are passed to the VM or to the builder command via options -Xcpus or -XcpusFromEnv.
NYI: UNDER DEVELOPMENT: From the Spec: Real-time threads and bound async event handlers that have processing group parameters are members of that processing group, and their processor affinity is governed by the intersection of the processing group's affinity and the schedulable object's affinity. The affinity set of a processing group must have exactly one processor, so the intersection of that set with the schedulable object's affinity set must contain at most one entry. If the intersection is empty the affinity defaults. Ordinarily, an execution context inherits its creator's affinity set, but: Java threads do not inherit affinity from SOs Unbound async event handlers cannot be assigned a non-default affinity. SOs do not inherit affinity from Java threads. When an execution context does not inherit its creator's affinity set, its initial affinity set defaults according to the rules specified: The default used when a heap-mode SO does not inherit its creator's affinity set, and for all unbound heap-mode async event handlers The default used when a no-heap SO does not inherit its creator's affinity set, and for all unbound no-heap async event handlers. The default used for Java threads created by SOs. This class also controls the default affinity used when a processing group is created using a constructor that does not assign a processing group. When the affinity set of a processing group is permitted to default, it defaults to the set of all available processors. (Which permits each member of the processing group to use the affinity set it would use if it were in no processing group.)
| Method Summary | |
|---|---|
static AffinitySet |
generate(java.util.BitSet bitSet)
Create an affinity set based on the given bitset of processors. |
static AffinitySet |
get(BoundAsyncEventHandler baeh)
return the affinity set that was set for a given async event handler. |
static AffinitySet |
get(ProcessingGroupParameters pgp)
Return the affinity set that was set for a given processing group. |
static AffinitySet |
get(java.lang.Thread thread)
Return the affinity set that was set for a given thread. |
static java.util.BitSet |
getAvailableProcessors()
Short hand for getAvailableProcessors(null). |
static java.util.BitSet |
getAvailableProcessors(java.util.BitSet dest)
Determine the set of processors that are currently available for the Java VM to execute Java code. |
static int |
getCurrentProcessor()
Return the id of the processor the current thread is running on. |
static AffinitySet |
getHeapSoDefaultAffinity()
Return the default CPU affinity set for schedulable objects that may access heap memory. |
static AffinitySet |
getJavaThreadDefaultAffinity()
Return the default CPU affinity set for non-RTSJ normal Java threads. |
static AffinitySet |
getNoHeapSoDefaultAffinity()
Return the default CPU affinity set for schedulable objects that run in no-heap mode. |
static AffinitySet |
getPGroupDefaultAffinity()
Return the default CPU affinity set for schedulable objects for which the intersection of their CPU affinity and the affinity set for their ProcessingGroupParameters is empty. |
static int |
getPredefinedAffinitySetCount()
Determine the number or predefined affinity sets. |
static AffinitySet[] |
getPredefinedAffinitySets()
Short hand for getPredefinedAffinitySets(null) |
static AffinitySet[] |
getPredefinedAffinitySets(AffinitySet[] dest)
Copy the set of all predefined affinity sets to an array |
java.util.BitSet |
getProcessors()
Return a newly allocated BitSet containing the CPU ids for the CPUs in this affinity set. |
java.util.BitSet |
getProcessors(java.util.BitSet dest)
Return a bitset containing the CPU ids for the CPUS in this affinity set. |
boolean |
isProcessorInSet(int processorNumber)
Check if a given processor is part of this affinity set |
static boolean |
isSetAffinitySupported()
Check whether affinity setting (via methods setProcessorAffinity(set,...) is supported by this VM. |
static void |
set(AffinitySet set,
BoundAsyncEventHandler baeh)
Set the CPU affinity of a given bound async event handler. |
static void |
set(AffinitySet set,
ProcessingGroupParameters pgp)
Set the processors affintiy of a given processing group parameters instance. |
static void |
set(AffinitySet set,
java.lang.Thread thread)
Set the CPU affinity of a given thread. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static AffinitySet generate(java.util.BitSet bitSet)
bitSet - the set of cpus that should be part of the set.
java.lang.NullPointerException - if bitSet == null;
java.lang.IllegalArgumentException - if bitSet does not have
cardinality one and bitSet is not equal to the processor set of
any AffinitySet returned by getAvailableProcessors().public static AffinitySet get(BoundAsyncEventHandler baeh)
baeh - the async event handler
java.lang.NullPointerException - if baeh == nullpublic static AffinitySet get(java.lang.Thread thread)
thread - the thread
java.lang.NullPointerException - if thread == nullpublic static AffinitySet get(ProcessingGroupParameters pgp)
pgp - the ProcessingGroupParameters of the processing group.
java.lang.NullPointerException - if pgp == nullpublic static java.util.BitSet getAvailableProcessors()
public static java.util.BitSet getAvailableProcessors(java.util.BitSet dest)
dest - a bitset to receive the set of available CPUs. May
be null to ask for allocation of a new bitset.
public static int getCurrentProcessor()
java.lang.UnsupportedOperationException - if this operation is not
supported on the current system.public static AffinitySet getHeapSoDefaultAffinity()
public static AffinitySet getJavaThreadDefaultAffinity()
public static AffinitySet getNoHeapSoDefaultAffinity()
public static AffinitySet getPGroupDefaultAffinity()
public static int getPredefinedAffinitySetCount()
public static AffinitySet[] getPredefinedAffinitySets()
public static AffinitySet[] getPredefinedAffinitySets(AffinitySet[] dest)
dest - (out!) the array the predefined sets should be copied
to, null to allocate a new array.
java.lang.IllegalArgumentException - in case dest!=null but
dest.length()public static boolean isSetAffinitySupported()
public static void set(AffinitySet set,
BoundAsyncEventHandler baeh)
throws ProcessorAffinityException
set - the affinity setbaeh - the bound async event hnalder whose CPU affinity is
to be set
java.lang.NullPointerException - if set == null or baeh == null
ProcessorAffinityException - if !isSetAffinitySupported.
public static void set(AffinitySet set,
java.lang.Thread thread)
throws ProcessorAffinityException
set - the CPU affinitythread - the thread whose affinity is to be set.
java.lang.NullPointerException - if set == null or thread == null.
ProcessorAffinityException - if !isSetAffinitySupported.
public static void set(AffinitySet set,
ProcessingGroupParameters pgp)
throws ProcessorAffinityException
set - the affinity setpgp - the ProcessingGroupParameters
java.lang.NullPointerException - if set == null or pgp == null.
ProcessorAffinityException - if !isSetAffinitySupported.public java.util.BitSet getProcessors()
public final java.util.BitSet getProcessors(java.util.BitSet dest)
dest - (out!) the bitset to store the result in, null to
force allocation of a new result.
public final boolean isProcessorInSet(int processorNumber)
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||