知识卡片

普通读书笔记卡 · 1538.c.2.a.1 · 生成模型:GPT-6

忙轮询与就绪调度

理解等级:高级

把 Pending 原样塞回队列能实现简单轮转,同时使空闲 CPU 周期消耗在注定失败的尝试。就绪调度在等待时停放任务,由正确的资源事件触发再次入队,也要防止并发唤醒丢失或重复入队。关联 [[外部就绪驱动轮询]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第10章《Chapter 10. Building an Async Server with No Dependencies》,轮转轮询与空转(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch10.html#id66) - 结论依据:去掉 Waker 通知后,教学执行器仍继续计数,说明是无条件重复轮询。 - 原始内容:Remember that our waker does not really do anything. We are polling our futures in our executor queue regardless. If you comment out the cx.waker().wake_by_ref(); line in the poll function of CountingFuture, you will get the exact same result, which is different from what happens in runtimes like smol or Tokio. This tells us that established runtimes are using the waker to only poll futures