并发 Haskell 仍然仅限于单个操作系统线程吗?

发布于 2024-09-14 07:25:16 字数 203 浏览 2 评论 0 原文

在 2005 年的一篇研究论文中说

并发 Haskell 目前仅针对单处理器实现。运行时在单个操作系统线程中调度轻量级 Haskell 线程。 Haskell 线程仅在明确定义的“安全点”处挂起;他们不能在任意时刻被先发制人。

这是否发生了变化,或者并发 Haskell 仍然仅限于单个操作系统线程?

In a 2005 research paper it said

Concurrent Haskell is currently implemented only for a uni-processor. The runtime schedules lightweight Haskell thread within a single operating system thread. Haskell threads are only suspended at well-defined “safe points”; they cannot be pre-empted at arbitrary moments.

Has this changed or is Concurrent Haskell still restricted to a single OS thread?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

喜你已久 2024-09-21 07:25:16

[编辑:问题只提到了 Concurrent Haskell,但我相信引用的论文是“Composable Memory Transactions”,该论文首次描述了 Haskell STM。如果我错了,请纠正我。]

STM 现在在多核上工作得很好。并行实现首先在 GHC 6.6 中发布,并使用细粒度的两阶段锁定策略;也就是说,要提交事务,实现首先尝试锁定事务中涉及的每个变量,然后提交更改,最后解锁所有变量。获取锁不会阻塞:如果锁已被持有,则事务将中止并重试(这可以避免在锁获取阻塞时出现的通常的锁顺序反转死锁)。

这种 STM 实现当然不是最快的 - 文献描述了许多可以带来更好性能的替代技术,但 GHC 的实现相对简单,并且不涉及任何全局锁(对不同变量集进行操作的事务可以并行进行而不会受到干扰) )。

[edit: the question only mentions Concurrent Haskell, but the paper referenced is, I believe, "Composable Memory Transactions", the paper in which Haskell STM was first described. Please correct me if I'm wrong here.]

STM works just fine on multiple cores now. The parallel implementation was first shipped in GHC 6.6, and uses a fine-grained two-phase locking strategy; that is, to commit a transaction the implementation first attempts to lock each variable involved in the transaction, then commits the changes, and finally unlocks all the variables. Acquiring a lock does not block: if the lock is already held, then the transaction aborts and retries (this avoids the usual lock-order-reversal deadlock that would apply if lock acquisition was blocking).

This STM implementation is certainly not the fastest - the literature describes many alternative techniques that would result in better performance, but GHC's implementation is relatively straightforward and doesn't involve any global locks (transactions operating on distinct sets of variables can proceed in parallel without interference).

分开我的手 2024-09-21 07:25:16

自 2004 年以来,GHC 可以使用多核来实现并发和并行 Haskell。并发、并行、嵌套数据并行 Haskell 都使用相同的多线程运行时。

GHC can use multi-cores for Concurrent and Parallel Haskell since 2004. Concurrent, Parallel, Nested Data Parallel Haskell all use the same multi-threaded runtime.

隐诗 2024-09-21 07:25:16

GHC Haskell 在多核上运行良好

GHC Haskell 程序,自 2004 年以来,在多个操作系统线程上运行多个 Haskell 线程,这些线程分布在多个内核上。

此外,您还可以从以下位置获取多核 Haskell 的最新状态这个问题。

GHC Haskell runs well on multicores

GHC Haskell programs, since 2004, run multiple Haskell threads over multiple OS threads, which are distributed over multiple cores.

Also, you can get the latest status of multicore Haskell from this SO question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文