仅用 Rust 编写的软件能否完全避免竞争条件?
Could software written only in Rust fully avoid race conditions?
维基百科 defines a race condition 如:
A race condition or race hazard is the behavior of an electronics, software, or other system where the output is dependent on the sequence or timing of other uncontrollable events. It becomes a bug when events do not happen in the order the programmer intended.
Rust is一个:
safe, concurrent, practical language
如果我们创建 100% Rust 的软件,我们可以避免竞争条件吗?为什么或者为什么不?
没有.
我在以下方面看到了竞争条件:
- 文件系统访问,
- 数据库访问,
- 访问其他服务。
程序在充满 data-races 的环境中进化,编程语言只能拥抱它。
Rust 专注于 memory-safety。在 multi-threaded 编程的上下文中,这意味着防止 数据竞争 。
没有数据竞争的程序仍然可以包含竞争条件:
- 数据竞争:在另一个线程 read/written 没有同步的情况下修改一个值,由此产生的行为是不可预测的(尤其是当涉及优化器时),
- 竞争条件:一系列事件的时间问题,由此产生的行为是一小组可能行为中的一个。可以通过同步来解决,但这不是唯一的解决办法
竞争条件不是内存错误。对于 Rust,这意味着它们被认为是 安全的 ,尽管它们当然仍然是不受欢迎的。它们可能发生在许多不同的级别:线程、进程、服务器之间,...
维基百科 defines a race condition 如:
A race condition or race hazard is the behavior of an electronics, software, or other system where the output is dependent on the sequence or timing of other uncontrollable events. It becomes a bug when events do not happen in the order the programmer intended.
Rust is一个:
safe, concurrent, practical language
如果我们创建 100% Rust 的软件,我们可以避免竞争条件吗?为什么或者为什么不?
没有.
我在以下方面看到了竞争条件:
- 文件系统访问,
- 数据库访问,
- 访问其他服务。
程序在充满 data-races 的环境中进化,编程语言只能拥抱它。
Rust 专注于 memory-safety。在 multi-threaded 编程的上下文中,这意味着防止 数据竞争 。
没有数据竞争的程序仍然可以包含竞争条件:
- 数据竞争:在另一个线程 read/written 没有同步的情况下修改一个值,由此产生的行为是不可预测的(尤其是当涉及优化器时),
- 竞争条件:一系列事件的时间问题,由此产生的行为是一小组可能行为中的一个。可以通过同步来解决,但这不是唯一的解决办法
竞争条件不是内存错误。对于 Rust,这意味着它们被认为是 安全的 ,尽管它们当然仍然是不受欢迎的。它们可能发生在许多不同的级别:线程、进程、服务器之间,...