gpt4 book ai didi

c# - 如何在 TwinCAT 中设置 1 个隔离核心

转载 作者:行者123 更新时间:2023-12-04 08:34:39 25 4
gpt4 key购买 nike

我必须从一个 c# 代码在 TwinCAT 中设置一个隔离的核心。在线文档中展示了如何设置内核数量、基本时间、内核限制和延迟警告,但没有关于隔离内核的数量。

public void AssignCPUCores()
{
ITcSysManager3 systemManager = project.Object;
ITcSmTreeItem realtimeSettings = systemManager.LookupTreeItem("TIRS");
string xml = null;
MemoryStream stream = new MemoryStream();
StringWriter stringWriter = new StringWriter();
using (XmlWriter writer = XmlTextWriter.Create(stringWriter))
{
writer.WriteStartElement("TreeItem");
writer.WriteStartElement("RTimeSetDef");
writer.WriteElementString("MaxCPUs", "4"); // looking at what changes in TwinCAT by changing this number,
// I found out that this number is the number of shared cores

string affinityString = string.Format("#x{0}", ((ulong)CpuAffinity.MaskDual).ToString("x16"));
//the MaskDual/MaskQuad/MaskSingle defines how many boxes will be checked (i.e. how many cores will be used)

writer.WriteElementString("Affinity", affinityString);
writer.WriteStartElement("CPUs");

// WriteCpuProperties(writer, int coreId , int loadLimit, int baseTime, latencyWarning)
WriteCpuProperties(writer, 0, 90, 1000, 0);

writer.WriteEndElement(); // CPUs
writer.WriteEndElement(); // RTimeSetDef
writer.WriteEndElement(); // TreeItem
}
xml = stringWriter.ToString();
realtimeSettings.ConsumeXml(xml); //here modifies are applied
ITcSmTreeItem tasks = systemManager.LookupTreeItem("TIRT");

SetTaskProperties(tasks, CpuAffinity.CPU1);
}
似乎没有办法设置隔离的内核。有可能吗?
目标是获得这样的东西:
enter image description here
但是抛出 c# 代码,隔离内核的数量为 0,并且所有内核在括号之间都有(共享)。

最佳答案

我不认为这是可能的。通常,当隔离内核的数量发生变化时,需要重新启动才能生效。如果你不用重启就可以用你的代码做到这一点,我会感到惊讶。

关于c# - 如何在 TwinCAT 中设置 1 个隔离核心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64855985/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com