Windows自身没有提供类似Linux cgroup的能力来限制进程或进程组的资源占用,进程CPU/IO/内存/网络等资源的控制只能由自己实现。目前已有第三方的实现,主要是限制进程CPU的占用,如文档 < 21 Best Ways to Limit the CPU Usage of a Process > 所描述的BES,Process Tamer等软件。自Windows 8及Server 2012开始Windows系统有提供以job为单位的CPU占用及内存上限设置,之前的版本则只能以进程或线程为单位进行限制。
进程CPU占用限制方案
即时轮询系统所有进程(线程)的CPU占用,当发现所设定进程有超标时强制暂停进程所有线程的执行,然后在适当的时机再恢复执行。其中所涉及技术点:
进程CPU占用查询 GetProcessTimes
BOOL GetProcessTimes(
[in] HANDLE hProcess,
[out] LPFILETIME lpCreationTime,
[out] LPFILETIME lpExitTime,
[out] LPFILETIME lpKernelTime,
[out] LPFILETIME lpUserTime
);
此函数可以获取进程从创建至当前的总运行时间及总的CPU时间,(KernelTime + UserTime) < 系统CPU数 * (当前时间 - CreationTime)
线程CPU占用查询 GetThreadTimes
BOOL GetThreadTimes(
[in] HANDLE hThread,
[out] LPFILETIME lpCreationTime,
[out] LPFILETIME lpExitTime,
[out] LPFILETIME lpKernelTime,
[out] LPFILETIME lpUserTime
);
QueryThreadCycleTime可以提供更精准的CPU时间数据,单位为CPU时钟周期
BOOL QueryThreadCycleTime(
[in] HANDLE ThreadHandle,
[out] PULONG64 CycleTime
);
线程暂停及恢复
Windows平台没有提供暂停整个进程的支持函数,只能以线程为单位来操作,即SuspendThread及ResumeThread:
DWORD SuspendThread(
[in] HANDLE hThread
);
DWORD ResumeThread(
[in] HANDLE hThread
);
CPU亲和性设置: SetProcessAffinityMask
BOOL SetProcessAffinityMask(
[in] HANDLE hProcess,
[in] DWORD_PTR dwProcessAffinityMask
);
此函数可以限定进程及其所有线程所能使用的CPU,故一定程序上亦限定了进程最大的系统CPU占用率。
DWORD_PTR SetThreadAffinityMask(
[in] HANDLE hThread,
[in] DWORD_PTR dwThreadAffinityMask
);
此函数可单独限制特定线程的CPU亲和性。
进程优先级设置: SetPriorityClass
优先级解决的是优先运行及退让CPU的问题,本质上并不能限定CPU占用,只是优先级高于当前任务的忙碌的时候,当前进程会主动退让CPU 线程优先级设置:SetThreadPriority
BOOL SetThreadPriority(
[in] HANDLE hThread,
[in] int nPriority
);
Job Objects
Windows系统提供了Job的概念用以管理多个进程,可以限制Job对象内所有进程及期线程的CPU核心占用、CPU占用及内存分配上限等,均通过SetInformationJobObject来实现,具体的CPU限制由JOBOBJECT_CPU_RATE_CONTROL_INFORMATION管理,内存限制则由JOBOBJECT_EXTENDED_LIMIT_INFORMATION来管理。
BOOL SetInformationJobObject(
[in] HANDLE hJob,
[in] JOBOBJECTINFOCLASS JobObjectInformationClass,
[in] LPVOID lpJobObjectInformation,
[in] DWORD cbJobObjectInformationLength
);
需要注意的是CPU占用设置只有Windows 8及Server 2012之后的版本有效。
CPU Sets
此部分只限定了CPU Affinity属性
实验验证
可以直接利用开源项目go-winjob验证,验证系统Windows 8 x64,go-winjob git repo: https://github.com/kolesnikovae/go-winjob
验证程序
#include <stdio.h>
#include <stdlib.h>
void main(int argc, char *argv[])
{
unsigned long total = 0, count = 0, i = 0;
while (1) {
if (malloc(1024)) {
total += 1024;
count++;
}
if (!(++i & 4095))
printf("alloc: %u size: %u bytes\n", count, total);
}
}
无限制
在无限制的情况下,此进程会占满一个CPU核心,commit内存总占用达2G

单一进程
在设定CPU上限16%及内存16M上限之后,结果如下:
examples/job_object.go按如下修改:
var limits = []winjob.Limit{
winjob.WithBreakawayOK(),
winjob.WithKillOnJobClose(),
winjob.WithActiveProcessLimit(3),
winjob.WithProcessTimeLimit(10 * time.Second),
winjob.WithCPUHardCapLimit(1600), // 16%
winjob.WithProcessMemoryLimit(16 << 20), // 16MB
winjob.WithWriteClipboardLimit(),
}
const defaultCommand = ".\\CPUStress.exe"
多进程(双进程)
将winjob.WithProcessMemoryLimit 改为 winjob.WithJobMemoryLimit,后者表示此job内所有进程要占用的总内存限制:
var limits = []winjob.Limit{
winjob.WithBreakawayOK(),
winjob.WithKillOnJobClose(),
winjob.WithActiveProcessLimit(3),
winjob.WithProcessTimeLimit(10 * time.Second),
winjob.WithCPUHardCapLimit(1600), // 16%
winjob.WithJobMemoryLimit(16 << 20), // 16MB
winjob.WithWriteClipboardLimit(),
}
验证结果如下:

winjob example代码:
// +build windows
package main
import (
"encoding/json"
"log"
"os"
"os/exec"
"os/signal"
"time"
"golang.org/x/sys/windows"
"github.com/kolesnikovae/go-winjob"
)
var limits = []winjob.Limit{
winjob.WithBreakawayOK(),
winjob.WithKillOnJobClose(),
winjob.WithActiveProcessLimit(3),
winjob.WithProcessTimeLimit(10 * time.Second),
winjob.WithCPUHardCapLimit(1600), // 16%
winjob.WithJobMemoryLimit(16 << 20), // 16MB
winjob.WithWriteClipboardLimit(),
}
const defaultCommand = ".\\CPUStress.exe"
const stressCommand = ".\\CPUStressX64.exe"
func main() {
job, err := winjob.Create("", limits...)
if err != nil {
log.Fatalf("Create: %v", err)
}
cmd := exec.Command(defaultCommand)
cmd.Stderr = os.Stderr
cmd.SysProcAttr = &windows.SysProcAttr{
CreationFlags: windows.CREATE_SUSPENDED,
}
if err := cmd.Start(); err != nil {
log.Fatalf("Start: %v", err)
}
stress := exec.Command(stressCommand)
stress.Stderr = os.Stderr
stress.SysProcAttr = &windows.SysProcAttr{
CreationFlags: windows.CREATE_SUSPENDED,
}
if err := stress.Start(); err != nil {
log.Fatalf("Start: %v", err)
}
s := make(chan os.Signal, 1)
signal.Notify(s, os.Interrupt)
c := make(chan winjob.Notification)
subscription, err := winjob.Notify(c, job)
if err != nil {
log.Fatalf("Notify: %v", err)
}
done := make(chan struct{})
go func() {
defer close(done)
ticker := time.NewTicker(time.Second * 5)
defer ticker.Stop()
var counters winjob.Counters
for {
select {
case <-s:
log.Println("Closing job object")
if err := job.Close(); err != nil {
log.Fatal(err)
}
log.Println("Closing subscription")
if err := subscription.Close(); err != nil {
log.Fatal(err)
}
return
case n, ok := <-c:
if ok {
log.Printf("Notification: %#v\n", n)
} else if err := subscription.Err(); err != nil {
log.Fatalf("Subscription: %v", err)
}
case <-ticker.C:
if err := job.QueryCounters(&counters); err != nil {
log.Fatalf("QueryCounters: %v", err)
}
b, err := json.MarshalIndent(counters, "", "\t")
if err != nil {
log.Fatal(err)
}
log.Printf("Counters: \n%s\n", b)
}
}
}()
if err := job.Assign(cmd.Process); err != nil {
log.Fatalf("Assign: %v", err)
}
if err := winjob.Resume(cmd); err != nil {
log.Fatalf("Resume: %v", err)
}
if err := job.Assign(stress.Process); err != nil {
log.Fatalf("Assign: %v", err)
}
if err := winjob.Resume(stress); err != nil {
log.Fatalf("Resume: %v", err)
}
if err := cmd.Wait(); err != nil {
log.Fatalf("Wait: %v", err)
}
if err := stress.Wait(); err != nil {
log.Fatalf("Wait: %v", err)
}
// Wait for a signal.
<-done
}
Nice article! Quick transactions and a large choice of games are exactly what I expect from a crypto casino like Article source .
Great post! One thing I find super helpful when reporting 404 errors is to always include the exact URL and, if possible, the time I encountered the error. It makes it way easier for the devs to track down the issue site migration broken links
For offices, ask about data-safe e-waste protocols. I booked compliant recycling via junk removal .
Информация об обращении не передается третьим лицам, а детали лечения обсуждаются только с пациентом.
Получить больше информации – http://vyvod-iz-zapoya-v-statsionare-v-gelendzhike2.ru
I’ve been trying Suprmind’s multi-model chat feature using GPT and Claude, and while it’s impressive to compare responses side-by-side, I found the steep learning curve a bit off-putting https://www.slideserve.com/aaron_ward92/where-can-i-find-suprmind-alternatives-on-directree
I recently used Suprmind’s Debate mode for a compliance review at my firm, and the ability to export discussions directly to DOCX saved me tons of formatting time. The $95/month price feels fair given the efficiency gains https://weekly-wiki.win/index.php/Suprmind_Enterprise_Pricing:_What_Does_Custom_Usually_Mean%3F
The Suprmind Open-Launch scheduled for Tuesday, July 28, 2026 at 08:00 AM UTC sounds intriguing, especially since it features five different models. I like that it’s built with Next.js and Node, which usually means a smooth web experience https://dantevrib041.fotosdefrases.com/how-do-i-compare-answers-across-models-without-cherry-picking
I didn’t realize battery storage changes how I use electricity. I’ll have Tesla Powerwall Installer Southern California explain optimal Powerwall settings.
I’ve been using Suprmind for market research, and it really helps me catch blind spots I would have missed otherwise. The way it structures information makes it easier to spot gaps without constantly switching between tabs Suprmind vs Grok
Small-scale living aligns well with current research on dementia-friendly design—simplified spaces, clear cues, and meaningful engagement. I encountered these concepts while reading assisted living .
I tried Suprmind mainly for the multi-model chat feature with GPT and Claude, and while it’s impressive to have all those options in one place, I found the interface a bit overwhelming at first get more info
I’ve been testing Suprmind during our compliance review process, and the Debate mode really helps clarify different perspectives on complex issues. The $95/month plan with export to DOCX makes it easy to share findings with our legal team Extra resources
Your guidance on evaluating communication from management (emails, calls, updates) is very realistic. We mention that on assisted living near me as well.
Excellent weblog right here! Also your website
quite a bit up fast! What host are you the use of? Can I am getting
your associate hyperlink for your host? I wish my web site
loaded up as fast as yours lol
Great post! One thing I’ve found helpful when dealing with 404 errors is to include the exact URL and the time you encountered the error when reporting it. That way, the team can track down the issue more quickly https://bfg5i.stick.ws/
I just saw that Suprmind’s open launch is set for Tuesday, July 28, 2026 at 08:00 AM UTC and involves five models on a web platform using Next.js and Node. It sounds promising but I’m a bit cautious since it’s a paid service AI model comparison chat
The natural eyebrow lift I got from Botox was subtle but noticeable. My Orange County injector came highly rated on Orange County Botox Injections .
I’ve been using Suprmind for due diligence, and it’s been a game-changer. It really helps me catch blind spots I might have missed otherwise. Plus, having everything in one place means I spend way less time switching between tabs https://titusssplendidperspective.almoheet-travel.com/suprmind-for-legal-analysis-can-it-review-contract-clauses
If your Southfield MI bathroom feels cramped, try some of the visual expansion tricks (mirrors, colors, tiles) I discovered on Asphalt Roof Installation Southfield MI .
This was highly informative. Check out treatment and medication guides for more.
I’ve been trying Suprmind for a few weeks now and the multi-model chat feature is impressive, especially how it pulls responses from GPT, Claude, and Gemini all at once how to compare AI models
I’ve been using Suprmind’s Debate mode during our pricing strategy sessions, and the way it frames opposing viewpoints really helps uncover hidden risks. The $95/month plan seemed steep at first, but the 7-day free trial convinced me Click here for more info
I like how you emphasized talking directly with current residents. That’s also one of the main suggestions we highlight on elder care .
Слушайте кто знает Отец не выходит из штопора Родственники не знают что делать Таблетки не помогают Короче, врачи приехали и поставили систему — вывод из запоя на дому спб анонимно Через пару часов человек пришёл в себя В общем, жмите чтобы сохранить — капельница на дом спб от алкоголя [url=https://alkogolizm.vyvod-iz-zapoya-na-domu-sankt-peterburg.ru]https://alkogolizm.vyvod-iz-zapoya-na-domu-sankt-peterburg.ru[/url] Вывод из запоя на дому — это реальный выход Перешлите тем кто в такой же ситуации
I saw the Suprmind Open-Launch is set for Tuesday, July 28, 2026, at 08:00 AM UTC and it’s a paid event. The use of Next.js and Node sounds promising for performance, but I’m curious how they plan to support five different models on the web without lag AI for strategy teams
I tried using Suprmind for due diligence and was impressed by how much it cut down on tab switching. Instead of jumping between documents and notes, I could keep everything streamlined in one place AI decision support platform
I’ve been trying Suprmind mainly for the multi-model chat feature with GPT and Claude, and it’s impressive to have different AI perspectives in one place https://solo.to/ryan_grant91
Люди помогите советом Муж просто потерял себя Соседи стучат в стену Нужна срочная помощь на дому Короче, только это реально спасло — вывод из запоя санкт Петербург недорого Через пару часов человек пришёл в себя В общем, телефон и цены тут — вывод из запоя спб стационар [url=https://kapelnicza.vyvod-iz-zapoya-na-domu-sankt-peterburg.ru]вывод из запоя спб стационар[/url] Не ждите пока станет хуже Перешлите тем кто в такой же ситуации
Financial planning and understanding what’s included in the monthly fee are so confusing. I’ve been using assisted living near me to line up questions before I talk with facilities.
I’ve been using Suprmind for due diligence reports, and the export to DOCX feature has been a lifesaver for quickly sharing drafts with my team. The $95/month pricing is reasonable for the level of detail and analysis it provides replace Claude Pro
Слушайте кто знает Муж просто потерял себя Дети напуганы В больницу тащить страшно Короче, только это реально спасло — вывод из запоя спб цены доступные Сняли ломку и стабилизировали состояние В общем, не потеряйте контакты — вывести из запоя цена [url=https://alkogolizm.vyvod-iz-zapoya-na-domu-sankt-peterburg.ru]https://alkogolizm.vyvod-iz-zapoya-na-domu-sankt-peterburg.ru[/url] Вывод из запоя на дому — это реальный выход Перешлите тем кто в такой же ситуации
I’ve been using Suprmind for due diligence, and it’s a game changer. It really helps catch blind spots I might have missed during the initial review. The fewer hallucinations make the whole process more reliable, saving me tons of verification time Grok vs Claude vs GPT
I tried Suprmind mainly because of the multi-model chat feature with GPT and Claude. Honestly, I found the interface a bit overwhelming at first, and the learning curve was steeper than I expected AI research workflow
Availability during weekends saved me time. Scheduling through junk removal services was super convenient.
Appreciate the insightful article. Find more at síntomas del reuma .
We added a strut to support a wide panel—clean work from garage door spring replacement Spring TX in The Woodlands.
The holistic approach at my local ##Everett Chiropractor## includes lifestyle changes which are super helpful! Chiropractor Everett
Does anyone know if there are any special offers at Northgate Chiropractors? Chiropractor in Northgate
Great post! One thing I always do when reporting 404 errors is include the exact URL and a screenshot with the timestamp. It really helps the dev team track down where and when it happened redirect chain
Professionalism topics in each market, and KMR Enterprises appears to provide itself with that prevalent. Visit design build contractors .
Здорова, народ Муж просто умирает на глазах Родственники в полном отчаянии В диспансер тащить — последнее дело Короче, спасла только госпитализация — наркология вывод из запоя в стационаре с психологом Выписали через неделю здоровым В общем, телефон и цены тут — вывод запоя телефон [url=https://lechenie.vyvod-iz-zapoya-v-staczionare-nizhnij-novgorod-elm.ru]вывод запоя телефон[/url] Звоните прямо сейчас Перешлите тем кто в беде
Слушайте кто знает Близкий человек уже две недели в запое Соседи уже вызвали участкового В диспансер тащить — последнее дело Короче, единственные кто взялся за безнадёжный случай — вывод из запоя стационар с круглосуточным наблюдением Положили в палату В общем, жмите чтобы сохранить — лечение запоя в стационаре [url=https://lechenie.vyvod-iz-zapoya-v-stacionare-samara12.ru]лечение запоя в стационаре[/url] Стационар — это единственный выход Это может спасти жизнь
Great post on 404 errors! One thing I always do when I spot one is to include the exact URL and the time I encountered it when reporting. Makes it way easier for the devs to track down and fix the problem website error message
Great post! One thing I’ve found helpful when dealing with 404 errors is to always include the full URL and a screenshot if possible when reporting the issue. It really speeds up troubleshooting why am I seeing 404
Switched to keypad entry for our Houston home cleaners with help from local emergency locksmith in Houston .
Wonderful tips! Discover more at commercial garage door repair .
I all the time used to study piece of writing in news papers but now
as I am a user of internet therefore from now I am using net for articles, thanks to web.
For postpartum support, intensive addiction treatment programs lists specialized programs for new moms and dads.
beste Casino zonder bonus
betalen met ideal
Appreciate the helpful advice. For more, visit pomoc drogowa .