PyPy中的GIL在哪里? [英] Where's the GIL in PyPy?

查看:139
本文介绍了PyPy中的GIL在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PyPy GIL是RPython中PyPy解释器实现的一部分,还是translate.py自动添加的东西?也就是说,如果我要用RPython编写自己的新语言解释器并通过translate.py运行它,那么它是否应该先于GIL,还是取决于我的解释器代码?

Is the PyPy GIL part of the PyPy interpreter implementation in RPython, or is it something that translate.py automatically adds? i.e., if I were to write my own new language interpreter in RPython and ran it through translate.py, would it be subject to the GIL a priori, or would that be up to my interpreter code?

推荐答案

GIL处理由module/thread/gil.py插入您的PyPy签出中.这是一项可选的翻译功能,仅在启用线程模块时才添加.就是说,RPython本身不是线程安全的语言(例如C),因此您需要注意正确锁定对象,以免出现不一致的情况.主要问题是提供一个线程感知的垃圾回收器,因为我们现在使用的那个不是线程安全的,仅添加一个锁将消除自由线程模型的很多好处.

The GIL handling is inserted by module/thread/gil.py in your PyPy checkout. It's an optional translation feature and it's only added when thread module is enabled. That said, RPython itself is not a thread-safe language (like for example C), so you would need to take care yourself to lock objects correctly, so they don't come up inconsistent. The main issue would be to provide a thread-aware garbage collector, because the one that we use right now is not thread safe and just adding a lock would remove a whole lot of benefits from a free-threading model.

干杯, 斐济

这篇关于PyPy中的GIL在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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