码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • dma epoll kernel thread


    Linux is using DMA and hardware interrupts when you use epoll. Even though the function has a name that makes it look like it would do “polling” where polling means “actively ask the network card over and over again in a loop if it has any data yet” that isn’t what it actually does. The problem here is that “poll” can either mean that constant active checking or it can mean calling any of the related system calls in Linux, poll, select, or epoll. The system calls are just a way of asking the kernel to put your process to sleep so it stops consuming CPU and wake your process back up once data is available so there is something for your program to actually do. It turns out the kernel will go and do that efficiently for you using hardware interrupts and DMA. So if somebody tells you their code is polling you can’t really know if it’s active tight loop checking or hardware interrupt-based without further clarification.

    The kernel will put your process to sleep and record what it was your process said it needed data for in order to wake up. Then when it gets a hardware interrupt from one of those data sources it will check the list of processes that were waiting to be woken up based on the availability of data from that source, and wake them up. It won’t endlessly ask the hardware if it has data in a tight loop.

    Ironically if you go high performance enough, things come back around the other way again. Having your process actually go to sleep and have the kernel wake it up has some overhead, so some network card vendors have proprietary kernel modules that make it so that your process can directly actively poll on a bit in memory that indicates whether the card has data, and the card flips it. Then your process can react without the program counter jumping into the interrupt handler and the kernel having to look up your process and notify you. But this means your process never goes to sleep, so you burn more power. So it’s less efficient in power use but more efficient in latency.

  • 相关阅读:
    【2022-8-27完美世界】完美世界图像算法岗笔试
    SD/SDIO(1):SD总线协议介绍
    常用网络编程函数
    《Span-based dual-decoder framework for aspect sentiment triplet extraction》论文阅读
    『力扣每日一题13』:给定一个整数sum,从有N个有序元素的数组中寻找元素a,b,使得a+b的结果最接近sum,最接近sum,最快的平均时间复杂度是?
    十个超级有用的JavaScript的高阶面试技巧!
    Spring源码学习笔记9——构造器注入及其循环依赖
    synchronized原理
    【Pandas数据处理100例】(八十七):Pandas使用get_dummies构建哑变量
    MXNet中图解稀疏矩阵(Sparse Matrix)的压缩与还原
  • 原文地址:https://blog.csdn.net/weixin_42756361/article/details/126823756
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号