纤维有优先级吗?
纤程被定义为轻量级线程,线程具有优先级,因为它们是抢占式调度的。然而,既然纤维是合作的,它们也有优先级吗?
Fibers are defined as lightweight threads, and threads have priorities because they are preemptively scheduled. However, since fibers are cooperative do they too have priorities?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,它们本质上没有优先级,就像在协作多任务中一样,上下文切换目标始终由移交控制权的代码片段确定(例如调用 Fiber.yield(),或者在您的实现中可能会调用它) )。
不过,这并不妨碍您实现调度程序来确定应用程序级别的下一次切换,然后应用程序可以再次根据优先级做出决定。
No, they intrinsically don't have priorities, as in cooperative multi-tasking, the context switch target is always determined by the piece of code handing off control (e.g. calling Fiber.yield(), or however it might be called in your implementation).
This doesn't keep you from implementing a scheduler to determine the next switching at the application level, though, which could then decide based on a priority again.