使用线程级内存保护/分页时存在哪些运行时问题?

发布于 2024-09-01 15:02:43 字数 444 浏览 6 评论 0原文

好的,我们今天支持每进程内存分页/保护。多年来我一直想知道,通过为当今操作系统支持的最小执行单元(线程)提供页级保护可以获得什么样的好处。 这个关于软件事务内存的问题带来了它回到我的最前沿。

拥有页面级线程所有权

  • 操作系统支持在访问时锁定页面的
  • 好处理论上,如果操作系统具有在线程生命周期内获取所有权的机制,则可以防止内存损坏。

缺点:

  • 标准的死锁检测 锁定技术已经 足够困难
  • 调试器/操作系统 支持确定页面级别 所有权

通过支持这种模式,您还可以看到其他任何缺点和优点吗?

Okay, so we support per-process memory paging/protection today. I've been wondering for years what sort of benefit is gained by offering page-level protections to what is arguably the smallest execution unit our OSes support today: threads. This question on Software Transactional Memory brought it back to the forefront for me.

Benefits to having page-level thread-ownership

  • OS support for locking the page when accessed
  • In theory, protection against memory corruption if the OS had a mechanism to take ownership for the lifetime of a thread.

Downsides:

  • Deadlock detection with standard
    locking techniques is already
    difficult enough
  • debugger/OS
    support for determining page-level
    ownership

Any other downsides, upsides that you can see from supporting such a model?

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

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

发布评论

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

评论(2

迷鸟归林 2024-09-08 15:02:43

这种编程模型已经可以通过进程和共享内存实现。它没有被太多使用,有充分的理由:进程间消息传递更加安全并且更容易推理。

This kind of programming model is already possible with processes and shared memory. It isn't used much, for good reason: interprocess message passing is far safer and easier to reason about.

若言繁花未落 2024-09-08 15:02:43

每线程每页内存保护可用于高效实现并行垃圾收集

要解决的问题是,为了收集某个区域的内存,垃圾收集器需要对该区域进行独占访问,否则其他线程(所谓的“mutator" 线程)将能够读取和写入状态不一致的对象(例如,从 oldspacenewspace)。

通过每线程内存保护,垃圾收集器可以控制对内存区域的访问,以便只有收集器线程可以访问它;其他线程尝试访问该内存区域将导致分段错误,这些错误可以由收集器处理(例如,通过阻塞线程直到收集器完成该区域)。

Per-thread per-page memory protection can be used to efficiently implement parallel garbage collection.

The problem to be solved is that in order to collect a region of memory, the garbage collector needs exclusive access to that region, otherwise other threads (so-called "mutator" threads) would be able to read and write objects that are not in a consistent state (for example, halfway through being copied from oldspace to newspace).

With per-thread memory protection, the garbage collector can control access to the region of memory so that only the collector thread can access it; attempts by other threads to access the region of memory will result in segmentation faults that can be handled by the collector (for example, by blocking the thread until the collector is finished with that region).

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