RtSetThreadCLOS

RtSetThreadCLOS overwrites a thread’s implicit or default Class of Services (CLOS), which is based on its priority when set to Priority-based CLOS performance mode. Otherwise, all Process threads are CLOS 0.

Syntax

Copy
BOOL RtSetThreadCLOS(
    HANDLE hThread,
    ULONG nCLOS
);

Parameters

hThread

The Process thread handle whose CLOS value is to be explicitly set.

nCLOS

A CLOS value from 0 to the number of CLOS – 1, where 0 identifies the highest performance, or DEFAULT_CLOS, which resets back to the implicit/default CLOS based on the thread’s priority. The number of CLOS is obtained by calling RtGetRDTCapability.

Return Value

If the function succeeds, it returns TRUE. If the argument is not valid, it returns FALSE.

Remarks

As a matter of eRTOS policy for extensibility, CLOS 0 is considered and configured as the highest priority CLOS, followed by CLOS 1, and so on.

A thread has implicit/default CLOS which is based on its priority when the kernel is configured to use Priority-based CLOS performance mode. The implicit/default CLOS and priority are inversely mapped with the Process priority range (0~127) by the number of CLOS available to Process processors/cores. With Flat performance mode the default CLOS is 0. Use real-time function RtGetRDTCapability to determine the number of CLOS.

For example, the mapping table below is for the number of CLOS equal to 7 when the kernel is configured to use Priority-based CLOS performance mode.

CLOS Process Priority Range
0 109~127
1 90~108
2 72~89
3 54~71
4 36~53
5 18~35
6 0~17

The implicit/default CLOS of Process thread can be overwritten by RtSetThreadCLOS. When the thread is scheduled to run, its CLOS is used to guide the hardware’s LLC fill policy and memory throttling.

As MBA controller is provided per processor core (the maximum of the delay values of the per-thread CLOS applies to the core), it is recommended to disable Hyper-Threading in the BIOS if the MBA Priority-based CLOS performance mode is configured.

Since MBA uses a programmable rate controller between the cores and the last-level shared caches and memory controller, bandwidth to these caches may also be reduced. Take care to throttle only bandwidth-intense threads that do not use the off-core caches effectively.

Requirements

Minimum supported version Header Library

eRTOS 1.0 SDK

RtssApi.h rtkrnl.lib

See Also: