1

我不喜欢编码,但我真的很喜欢 Ada,而且我对它很陌生。那么你能向我澄清这些观点吗?

如果您的计算机具有单个非线程 CPU,则任务仍然是单 CPU。当然,这同样适用于 C 或 C++中的分叉。

问题:你认为在这种情况下,Ada 任务分配比分叉有什么好处吗?

我也想知道为什么 SPARK 禁止任务分配(我知道这是为了安全,但确切地说,禁止任务分配如何提高安全性。)

我的第三个也是最后一个问题,如果我想提供“安全任务”(在 Ada 中),我可以设想哪些任务限制才能使使用它们(任务)“安全”。

谢谢,

4

1 回答 1

1

1) Yes. The easiest argument being that Ada tasks run in the same process context, making tasks/threads somewhat faster than separate processes. The language level inter-task communication and synchronisation features are another reason.

2) Only some versions of SPARK prohibit tasking. RavenSPARK (2005) allows tasking, and allows formal reasoning about tasking. The problem with tasking is that it is hard to reason formally about, especially with the ambitions of the SPARK team (proving correctness).

3) You could consider limiting yourself to the Ravenscar profile. But plain Ada tasking is already relatively safe (even if it can't prevent you from writing nice dead-locks).

于 2015-06-22T22:27:50.313 回答