What's *Deterministic concurrency*?

我的梦境 提交于 2019-12-05 03:26:23

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.

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.

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.

I haven't heard the term before, but coroutines come to mind. They don't provide "true" concurrency, in the sense that only one routine is executing at any particular moment, but they're concurrent in the sense that a group of interacting coroutines can all make progress without having to wait for each other to finish.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!