Simulate CFS bandwidth control in 1 ms ticks.
Input: quota period threads work cores (quota and period in ms; each of threads threads needs work ms of CPU; the machine has cores cores). All threads start at t = 0.
In each 1 ms tick: the quota is refilled at the start of every period (t = 0, period, 2 × period, …); the number of threads that run is min(runnable threads, cores, remaining quota); running threads (lowest index first) each progress 1 ms and consume 1 ms of quota. A period is throttled if at some tick fewer threads ran than min(runnable, cores) because the quota was exhausted.
Print:
Limit: 0.20 CPUs (quota 20 ms per 100 ms)
Work: 1 thread x 50 ms on 4 cores
Finish time: 210 ms (without limit: 50 ms), throttled periods: 2
(limit as an integer if whole, else 2 decimals; "without limit" = ⌈threads × work / min(threads, cores)⌉.)