Udostępnij za pośrednictwem


Process.GetExclusiveCores Method

Definition

On some devices, the foreground process may have one or more CPU cores exclusively reserved for it.

[Android.Runtime.Register("getExclusiveCores", "()[I", "", ApiSince=24)]
public static int[]? GetExclusiveCores ();
[<Android.Runtime.Register("getExclusiveCores", "()[I", "", ApiSince=24)>]
static member GetExclusiveCores : unit -> int[]

Returns

Int32[]

an array of integers, indicating the CPU cores exclusively reserved for this process. The array will have length zero if no CPU cores are exclusively reserved for this process at this point in time.

Attributes

Remarks

On some devices, the foreground process may have one or more CPU cores exclusively reserved for it. This method can be used to retrieve which cores that are (if any), so the calling process can then use sched_setaffinity() to lock a thread to these cores. Note that the calling process must currently be running in the foreground for this method to return any cores.

The CPU core(s) exclusively reserved for the foreground process will stay reserved for as long as the process stays in the foreground.

As soon as a process leaves the foreground, those CPU cores will no longer be reserved for it, and will most likely be reserved for the new foreground process. It's not necessary to change the affinity of your process when it leaves the foreground (if you had previously set it to use a reserved core); the OS will automatically take care of resetting the affinity at that point.

Java documentation for android.os.Process.getExclusiveCores().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to