什么是*确定性并发*? [英] What's *Deterministic concurrency*?

查看:217
本文介绍了什么是*确定性并发*?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说有3种并发。


  1. 确定性并发

  2. 传递并发

  3. 共享状态并发

我知道#2 #3(=一般线程),但不是#1。

I know #2 (=actor model) and #3 (=general threading), but not #1. What's that?

推荐答案

确定性并发是一个并发编程模型,使得在此模型中编写的程序具有以下属性:对于任何执行计划,程序的输出值是相同的。这意味着程序的输出完全取决于程序的输入。

Deterministic concurrency is a concurrent programming model such that programs written in this model have the following property: for a given set of inputs, the output values of a program are the same for any execution schedule. This means that the outputs of the program depend solely on the inputs of the program.

有一些方法可以确保这个属性。其中一种方法是所谓的单赋值编程,其中变量不必被初始化,但是最多可以赋值一次。读取未初始化的变量会停止,直到它被分配一个值(可能由其他线程)。 Mozart编程语言支持这些。

There are ways to ensure this property. One of the ways is the so-called single-assignment programming where variables don't have to be initialized, but may be assigned at most once. Reading an uninitialized variable stalls until it's assigned a value (possibly by some other thread). The Mozart programming language has support for these.

另一种方法是使用所有权分析来确定哪些线程拥有不同的引用,并确保没有2个线程写入在同一时间的引用,所以没有数据竞争。

Another way is to use ownership analysis to determine which threads 'own' different references, and to ensure that no 2 threads write to the reference at the same 'time', so there are no data races.

这篇关于什么是*确定性并发*?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆