Stackless Python is an enhanced
version of the Python programming
language. It allows programmers to
reap the benefits of thread-based
programming without the performance
and complexity problems associated
with conventional threads. The
microthreads that Stackless adds to
Python are a cheap and lightweight
convenience which can if used
properly, give the following benefits:
Stackless python没有利用它运行的任何类型的多核环境 这是关于Stackless的常见误解,因为它允许程序员利用基于线程的编程。对许多人来说,这两者紧密地交织在一起,但实际上是两个独立的东西。
在内部Stackless使用循环调度程序来调度每个tasklet(微线程),但是没有一个tasklet可以与另一个tasklet并发运行。这意味着,如果一个微线程正忙,其他微线程必须等到该微线程放弃控制。默认情况下,调度程序不会停止一个tasklet并给另一个tasklet分配处理器时间。tasklet的责任是使用Stackless.schedule()将自身调度回调度队列的末尾,或者完成其计算。
因此,所有微线程都是按顺序执行的,即使有多个核心可用。
Stackless没有多核支持的原因是这使得线程变得更加容易。这正是stackless的意义所在:
from the official stackless website
这里有一个link来获得更多关于多核和无堆栈的信息。
相关问题 更多 >
编程相关推荐