设置小蓝熊的CPU亲和性、CPU优先级再设置法环的CPU亲和性

# 适用于Windows系统
# @时间    : 2024-06-28
# @作者    : 三巧(https://blog.csdn.net/qq_39124701)
# @文件名  : 设置小蓝熊的CPU亲和性、CPU优先级再设置法环的CPU亲和性.ps1
# @使用方法: 打开记事本,将所有代码复制到记事本中,保存文件时候修改文件后缀为".ps1"。
#            右键该文件,点击"使用 PowerShell 运行"即可。



# 定义设置CPU亲和性的函数
function Set-ProcessCpuAffinity {
    param(
        [Diagnostics.Process]$Process,
        [int[]]$Affinity
    )
    
    # 获取Process的句柄
    $handle = $Process.Handle
    $processAffinityMask = 0
    $systemAffinityMask = 0

    # 循环设置CPU亲和性掩码
    for ($i = 0; $i -lt $Affinity.Length; $i++) {
        $cpu = $Affinity[$i]
        $processAffinityMask = $processAffinityMask -bor [int](1 -shl $cpu)
        $systemAffinityMask = $systemAffinityMask -bor [int](1 -shl $cpu)
    }

    # 设置进程亲和性
    $success = [Kernel32]::SetProcessAffinityMask($handle, $processAffinityMask)
    if (-not $success) {
        Write-Error "Unable to set process affinity."
    }

    # 设置系统亲和性
    $success = [Kernel32]::SetProcessAffinityMask($handle, $systemAffinityMask)
    if (-not $success) {
        Write-Error "Unable to set system affinity."
    }
}

# 导入Kernel32.dll
Add-Type -TypeDefinition @"
    using System;
    using System.Runtime.InteropServices;

    public class Kernel32 {
        [DllImport("kernel32.dll", SetLastError = true)]
        public static extern bool SetProcessAffinityMask(IntPtr handle, IntPtr affinityMask);
    }
"@

# 使用WMI获取逻辑处理器数  
$logicalProcessors = (Get-WmiObject Win32_ComputerSystem).NumberOfLogicalProcessors  



# 定义要设置CPU亲和性的CPU编号数组(EAC)
# $cpuAffinity = 1, 2  # 例如,只使用CPU 1和CPU 2
$cpuAffinity = 0  # 只使用CPU0

# 获取已经运行的EasyAntiCheat_EOS.exe进程对象
$eac = Get-Process -Name "EasyAntiCheat_EOS" -ErrorAction SilentlyContinue

if ($null -ne $eac) {
    # 调用函数设置CPU亲和性
    Set-ProcessCpuAffinity -Process $eac -Affinity $cpuAffinity


    # 定义要设置的优先级(Idle:空闲)
    $priorityClass = [System.Diagnostics.ProcessPriorityClass]::Idle
    # 设置进程的优先级
    $eac.PriorityClass = $priorityClass
    # 显示设置结果
    if ($eac.PriorityClass -eq $priorityClass) {
        Write-Host "Priority class set to $([enum]::GetName([System.Diagnostics.ProcessPriorityClass], $priorityClass))"
    } else {
        Write-Error "Failed to set priority class."
    }
} else {
    Write-Host "EasyAntiCheat_EOS.exe is not running."
}

# 定义要设置CPU亲和性的CPU编号数组(法环)
# $cpuAffinity = 1,2,3,4,5,6,7,8,9,10,11  #(写死数字的方法只适用于12核心的处理器)
$cpuAffinity = 1..($logicalProcessors - 1) # 从1开始,也就是除了 CPU0 都使用

# 获取已经运行的eldenring.exe进程对象
$er = Get-Process -Name "eldenring" -ErrorAction SilentlyContinue

if ($null -ne $er) {
    # 调用函数设置CPU亲和性
    Set-ProcessCpuAffinity -Process $er -Affinity $cpuAffinity
} else {
    Write-Host "eldenring.exe is not running."
}


Write-Host ""
Write-Host "Script execution completed successfully!"
Read-Host -Prompt "Press Enter to quit"






请添加图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/754947.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Hugging Face Accelerate 两个后端的故事:FSDP 与 DeepSpeed

社区中有两个流行的零冗余优化器 (Zero Redundancy Optimizer,ZeRO)算法实现,一个来自DeepSpeed,另一个来自PyTorch。Hugging FaceAccelerate对这两者都进行了集成并通过接口暴露出来,以供最终用户在训练/微调模型时自主选择其中之…

zabbix-server的搭建

zabbix-server的搭建 部署 zabbix 服务端(192.168.99.180) rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm cd /etc/yum.repos.d sed -i s#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix# zabbix.r…

关于FPGA对 DDR4 (MT40A256M16)的读写控制 4

关于FPGA对 DDR4 (MT40A256M16)的读写控制 4 语言 :Verilg HDL 、VHDL EDA工具:ISE、Vivado、Quartus II 关于FPGA对 DDR4 (MT40A256M16)的读写控制 4一、引言二、DDR4 SDRAM设备中模式寄存器重要的模式寄存…

Arduino - LED 矩阵

Arduino - LED 矩阵 Arduino - LED Matrix LED matrix display, also known as LED display, or dot matrix display, are wide-used. In this tutorial, we are going to learn: LED矩阵显示器,也称为LED显示器,或点阵显示器,应用广泛。在…

“Hello, World!“ 历史由来

布莱恩W.克尼汉(Brian W. Kernighan)—— Unix 和 C 语言背后的巨人 布莱恩W.克尼汉在 1942 年出生在加拿大多伦多,他在普林斯顿大学取得了电气工程的博士学位,2000 年之后取得普林斯顿大学计算机科学的教授教职。 1973 年&#…

C++ | Leetcode C++题解之第203题移除链表元素

题目: 题解: class Solution { public:ListNode* removeElements(ListNode* head, int val) {struct ListNode* dummyHead new ListNode(0, head);struct ListNode* temp dummyHead;while (temp->next ! NULL) {if (temp->next->val val) {…

小柴冲刺软考中级嵌入式系统设计师系列一、计算机系统基础知识(1)嵌入式计算机系统概述

flechazohttps://www.zhihu.com/people/jiu_sheng 小柴冲刺嵌入式系统设计师系列总目录https://blog.csdn.net/qianshang52013/article/details/139975720?spm1001.2014.3001.5501 根据IEEE(国际电气电子工程师协会)的定义,嵌入式系统是&q…

Linux高并发服务器开发(六)线程

文章目录 1. 前言2 线程相关操作3 线程的创建4 进程数据段共享和回收5 线程分离6 线程退出和取消7 线程属性(了解)8 资源竞争9 互斥锁9.1 同步与互斥9.2 互斥锁 10 死锁11 读写锁12 条件变量13 生产者消费者模型14 信号量15 哲学家就餐 1. 前言 进程是C…

哪吒汽车,正在等待“太乙真人”的拯救

文丨刘俊宏 在360创始人、哪吒汽车股东周鸿祎近日连续且着急的“督战”中,哪吒汽车(下简称哪吒)终究还是顶不住了。 6月26日,哪吒通过母公司合众新能源在港交所提交了IPO文件,急迫地希望成为第五家登陆港股的造车新势力…

uniapp中实现瀑布流 短视频页面展示

直接上干货 第一部分为结构 <swiper class"list" :currentindex change"swiperchange" scrolltolower"onReachBottom"><swiper-item style"overflow: scroll;" v-for"(item,index) in 2" :key"index"&g…

DataV大屏组件库

DataV官方文档 DataV组件库基于Vue &#xff08;React版 (opens new window)&#xff09; &#xff0c;主要用于构建大屏&#xff08;全屏&#xff09;数据展示页面即数据可视化&#xff0c;具有多种类型组件可供使用&#xff1a; 源码下载

Golang | Leetcode Golang题解之第204题计数质数

题目&#xff1a; 题解&#xff1a; func countPrimes(n int) int {primes : []int{}isPrime : make([]bool, n)for i : range isPrime {isPrime[i] true}for i : 2; i < n; i {if isPrime[i] {primes append(primes, i)}for _, p : range primes {if i*p > n {break}…

智能交通(1)——杭州交通数据集

赛题简介 在本地赛题中&#xff0c;参赛团队需要在平台提供的仿真交通场景下&#xff0c;通过算法模型驱动交通信号灯&#xff0c;以在各种交通状况&#xff08;高峰期、雨天等&#xff09;下都能最大程度地服务车辆&#xff0c;使其在模拟环境中获得综合最大得分。 数据集 …

Docker 部署 MariaDB 数据库 与 Adminer 数据库管理工具

文章目录 MariaDBmariadb.cnf开启 binlog Adminerdocker-compose.ymlAdminer 连接 MariaDB MariaDB MariaDB是一个流行的开源关系型数据库管理系统&#xff08;RDBMS&#xff09;&#xff0c;它是MySQL的一个分支和替代品。 官网&#xff1a;https://mariadb.com/镜像&#xff…

GPU算力是什么,哪些行业需要用到GPU算力?

近两年&#xff0c;计算能力已成为推动各行各业发展的关键因素。而GPU&#xff08;图形处理器&#xff09;算力&#xff0c;作为现代计算技术的重要分支&#xff0c;正逐渐在多个领域展现出其强大的潜力和价值。尚云将简要介绍GPU算力的定义和基本原理&#xff0c;并探讨其在哪…

对于CDA一级考试该咋准备??!

一、了解考试内容和结构 CDA一级考试主要涉及的内容包括&#xff1a;数据分析概述与职业操守、数据结构、数据库基础与数据模型、数据可视化分析与报表制作、Power BI应用、业务数据分析与报告编写等。 CDA Level Ⅰ 认证考试大纲:https://edu.cda.cn/group/4/thread/174335 …

从架构设计的角度分析ios自带网络库和AFNetworking

总结&#xff08;先说明文章分析出的一些‘认知’&#xff09; 从本文中&#xff0c;我们可以总结出一些框架设计上的“认知”&#xff1a; 对于通用的常规配置信息方面的设计&#xff0c;我们可以通过定义一个“类似于NSURLSessionConfiguration、NSURLRequest”的类来完成设…

Python | Leetcode Python题解之第203题移除链表元素

题目&#xff1a; 题解&#xff1a; # Definition for singly-linked list. # class ListNode: # def __init__(self, val0, nextNone): # self.val val # self.next next class Solution:def removeElements(self, head: ListNode, val: int) -> Li…

ArkTS自定义组件

一、自定义组件基本结构 // 定义自定义组件 ButtonCom.ets Component export struct BtnCom{State msg: string "按钮";build() {Row(){Text(this.msg).onClick(() > {this.msg "测试"})}} } // 引入自定义组件 import {BtnCom} from "./Butto…

[Go Web] Kratos 使用的简单总结

文章目录 1.Kratos 简介2.传输协议3.日志4.错误处理5.配置管理6.wire 1.Kratos 简介 Kratos并不绑定于特定的基础设施&#xff0c;不限定于某种注册中心&#xff0c;或数据库ORM等&#xff0c;所以您可以十分轻松地将任意库集成进项目里&#xff0c;与Kratos共同运作。 API -&…