CPU throttling

Questions and Answers about all things *OS (macOS, iOS, tvOS, watchOS)

CPU throttling

Postby septium » Fri Nov 23, 2018 8:11 pm

How to perform CPU throttling on jailbroken iDevices like Apple does (low power mode in Settings, throttling on weak battery, etc.)?
Posts: 38
Joined: Thu May 04, 2017 10:04 am

Re: CPU throttling

Postby morpheus » Fri Nov 23, 2018 9:41 pm

That's a GREAT question. I actually just finished the detailed explanation in volume II. The short version is that there is a CPUmon facility, which uses ledgers (a Mach primitive) to keep track of resource utilization, and generate a Mach exception when resource usage is exceeded.

lib system exports these APIs for new (posix spawned) processes and existing ones:

0000000000018e33 T _posix_spawnattr_getcpumonitor
0000000000018e16 T _posix_spawnattr_setcpumonitor
00000000000087c3 T _posix_spawnattr_setcpumonitor_default
000000000000823e T _proc_disable_cpumon
00000000000064bd S _proc_get_cpumon_params
00000000000182ad T _proc_resume_cpumon
00000000000066e5 S _proc_set_cpumon_defaults
00000000000032e1 S _proc_set_cpumon_params
00000000000182e4 T _proc_set_cpumon_params_fatal

and you can see the implementation of that pretty clearly in XNU's sources. At least for 2-3 weeks till I get the book out..

And I'm adding this till then:

Screen Shot 2018-11-23 at 16.57.32.png
Screen Shot 2018-11-23 at 16.57.32.png (832.53 KiB) Viewed 392 times

EDIT: And the best way to do resource throttling is proc_rlimit_control (#446) which I nearly forgot! Thank you for reminding me before I push out v1.2 of Volume I....
Site Admin
Posts: 687
Joined: Thu Apr 11, 2013 6:24 pm

Return to Questions and Answers

Who is online

Users browsing this forum: No registered users and 4 guests