6 ms·
I'm not an expert on the subject but just happen to know this was possible since XP: https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-jobobjec
by marwis 3y ago
I'm not an expert on the subject but just happen to know this was possible since XP: https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-jobobject_basic_limit_information https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns...
See JOB_OBJECT_LIMIT_PROCESS_MEMORY and JOB_OBJECT_LIMIT_PROCESS_TIME.
Job is basically Windows equivalent of Linux Control Group.
- dataflow 3y agoNo, the CPU one isn't the same. It's a cumulative limit (resulting in termination when exceeded). The parent is asking for rate limits (resulting in throttling when exceeded).
- marwis 3y agoIt's not really clear from OP that it's about rate. Cumulative limit would still fulfill requirement of stopping while(true) from exhausting resources. But if you need rate there's this: JOB_OBJECT_ CPU_RATE_CONTROL_MIN_MAX_RATE https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-jobobject_cpu_rate_control_information https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns...
- deleted 3y ago[deleted]
- dataflow 3y agoIt's not explicitly written, but it's a pretty unavoidable conclusion. As far as the verbiage goes -- "doesn't exhaust" means "uses less than the full amount available". Given that "total CPU time" isn't something you can run out of, "doesn't exhaust CPU" can only mean "uses less CPU than is currently available", i.e. "utilizes < 100% of the CPU", i.e. throttling. As a practical matter, pretty much ~no user wants to kill a program after N seconds, and ~no program can limit itself to N seconds of work, either. People just want their CPU to have bandwidth to do other work, avoid heating up, etc. So unless you have a strong reason to believe otherwise, it's fair to assume people want to limit CPU utilization, not total CPU time.
- mike_hearn 3y ago> pretty much ~no user wants to kill a program after N seconds This is exactly how the web and cloud FaaS like AWS Lambda does it, so I don't think it's right to say nobody wants this. Runaway code does need to be killed.
- dataflow 3y agoI didn't say nobody wants this, I said no user wants this. We're not talking web servers, we're talking about Windows desktop apps here... with humans using them. User != admin != owner. "Web and cloud FaaS like AWS Lambda" don't have "users" (i.e. the kind who would say "this shouldn't exhaust my system resources" like the parent did). They're cattle, running batch jobs, and/or serving APIs that other client applications invoke...
- mike_hearn 3y agoWeb pages have users (JS has time limited execution and will be killed if the page hangs).
- dataflow 3y agoAre you under the impression web pages can access the Win32 API?