1# Related Thread Group 2 3 4## Basic Concepts 5 6The Related Thread Group (RTG) provides optimized scheduling of a group of important threads. The load of an RTG can be collected and predicted separately and the preferred CPU cluster can be set to allow the important threads to run on the optimal CPU and the kernel to select a proper CPU frequency based on the group loads. 7 8 9## Configuration 10 11### Enabling RTG 12To enable RTG, you need to enable the related configuration items and dependencies during kernel compilation. The related configuration items are as follows: 13 14``` 15CONFIG_SCHED_RTG=y 16CONFIG_SCHED_RTG_DEBUG=y 17CONFIG_SCHED_RTG_FRAME=y 18CONFIG_SCHED_RTG_RT_THREAD_LIMIT=y 19``` 20 21Enable the following dependencies: 22 23``` 24CONFIG_SCHED_WALT=y 25``` 26### Adding a Process or Thread to an RTG 27 28By default, 20 RTGs are created in the kernel. The group with ID of 1 is reserved and cannot be added with any process or thread. 29 30```Bash 31// Add a process to an RTG. 32echo 2 > /proc/<pid>/sched_group_id 33// Remove a process from an RTG. The group with ID of 0 is not an RTG. 34echo 0 > /proc/<pid>/sched_group_id 35``` 36### Obtaining RTG Information 37 38The RTG information includes group ID, preferred CPU cluster ID, and thread information. 39 40 ```Bash 41cat /proc/sched_rtg_debug 42// The following information is displayed: 43RTG_ID : 2 // RTG ID. 44RTG_INTERVAL : UPDATE:8ms\#INVALID:4294ms // CPU frequency modulation interval and valid load duration. 45RTG_CLUSTER : -1 // CPU cluster ID. The value **-1** means that the preferred cluster is not set. 46RTG_THREADS: 0/1 // Total number of threads in the group. 47STATE COMM PID PRIO CPU // Thread information, including the status, name, PID, priority, and CPU ID. 48--------------------------------------------------------- 49 S bash 436 120 1(0-3) 50 ``` 51